Smile\ElasticsuiteVirtualCategory\Model\Rule::getCategorySearchQuery PHP Method

getCategorySearchQuery() public method

Build search query by category.
public getCategorySearchQuery ( Magento\Catalog\Api\Data\CategoryInterface $category, array $excludedCategories = [] ) : Smile\ElasticsuiteCore\Search\Request\QueryInterface
$category Magento\Catalog\Api\Data\CategoryInterface Search category.
$excludedCategories array 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
    public function getCategorySearchQuery($category, $excludedCategories = [])
    {
        if (!is_object($category)) {
            $category = $this->categoryFactory->create()->setStoreId($this->getStoreId())->load($category);
        }
        $queryParams = ['cached' => true];
        if ((bool) $category->getIsVirtualCategory() && $category->getIsActive()) {
            $excludedCategories[] = $category->getId();
            $queryParams['must'][] = $this->getVirtualCategoryQuery($category, $excludedCategories);
            $parentCategory = $this->getVirtualRootCategory($category);
            if ($parentCategory && $parentCategory->getId()) {
                $queryParams['must'][] = $this->getCategorySearchQuery($parentCategory, $excludedCategories);
            }
        } elseif ($category->getId() && $category->getIsActive()) {
            $queryParams['should'][] = $this->getStandardCategoryQuery($category);
            foreach ($this->getChildrenVirtualCategories($category, $excludedCategories) as $childrenCategory) {
                $queryParams['should'][] = $this->getVirtualCategoryQuery($childrenCategory, $excludedCategories);
            }
        }
        return $this->queryFactory->create(QueryInterface::TYPE_BOOL, $queryParams);
    }