public function getCategorySearchQuery($category, $excludedCategories = [])
    {
        $query         = null;

        if (!is_object($category)) {
            $category = $this->categoryFactory->create()->setStoreId($this->getStoreId())->load($category);
        }

        if (!in_array($category->getId(), $excludedCategories)) {
            $excludedCategories[] = $category->getId();

            if ((bool) $category->getIsVirtualCategory() && $category->getIsActive()) {
                $query = $this->getVirtualCategoryQuery($category, $excludedCategories);
            } elseif ($category->getId() && $category->getIsActive()) {
                $query = $this->getStandardCategoryQuery($category, $excludedCategories);
            }
            if ($query && $category->hasChildren()) {
                $query = $this->addChildrenQueries($query, $category, $excludedCategories);
            }
        }

        return $query;
    }
public function getCategorySearchQuery($category, $excludedCategories = [])
    {
        $query         = null;

        if (!is_object($category)) {
            $category = $this->categoryFactory->create()->setStoreId($this->getStoreId())->load($category);
        }

        if (!in_array($category->getId(), $excludedCategories)) {
            $excludedCategories[] = $category->getId();

            if ((bool) $category->getIsVirtualCategory() && $category->getIsActive()) {
                $query = $this->getVirtualCategoryQuery($category, $excludedCategories);
            } elseif ($category->getId() && $category->getIsActive()) {
                $query = $this->getStandardCategoryQuery($category, $excludedCategories);
            }
            if ($query && $category->hasChildren()) {
                $query = $this->addChildrenQueries($query, $category, $excludedCategories);
            }
        }

        return $query;
    }
public function getCategorySearchQuery ( $ category , $ excludedCategories = [ ] ) { $ query = null ; if ( ! is_object ( $ category ) ) { $ category = $ this -> categoryFactory -> create ( ) -> setStoreId ( $ this -> getStoreId ( ) ) -> load ( $ category ) ; } if ( ! in_array ( $ category -> getId ( ) , $ excludedCategories ) ) { $ excludedCategories [ ] = $ category -> getId ( ) ; if ( ( bool ) $ category -> getIsVirtualCategory ( ) && $ category -> getIsActive ( ) ) { $ query = $ this -> getVirtualCategoryQuery ( $ category , $ excludedCategories ) ; } elseif ( $ category -> getId ( ) && $ category -> getIsActive ( ) ) { $ query = $ this -> getStandardCategoryQuery ( $ category , $ excludedCategories ) ; } if ( $ query && $ category -> hasChildren ( ) ) { $ query = $ this -> addChildrenQueries ( $ query , $ category , $ excludedCategories ) ; } } return $ query ; }
Build search query by category.

@param \Magento\Catalog\Api\Data\CategoryInterface $category           Search category.
@param array                                       $excludedCategories Categories that should not be used into search
query building. Used to avoid infinite recursion
while building virtual categories rules.

@return \Smile\ElasticsuiteCore\Search\Request\QueryInterface
Build search query by category .