private function getVirtualCategoryQuery(CategoryInterface $category, $excludedCategories = [])
    {
        $query          = $category->getVirtualRule()->getConditions()->getSearchQuery($excludedCategories);
        $parentCategory = $this->getVirtualRootCategory($category);

        if ($parentCategory && in_array($parentCategory->getId(), $excludedCategories)) {
            $query = null;
        } if ($parentCategory && $parentCategory->getId()) {
            $parentQuery = $this->getCategorySearchQuery($parentCategory, $excludedCategories);
            if ($parentQuery) {
                $query = $this->queryFactory->create(QueryInterface::TYPE_BOOL, ['must' => [$query, $parentQuery]]);
            }
        }

        return $query;
    }
private function getVirtualCategoryQuery(CategoryInterface $category, $excludedCategories = [])
    {
        $query          = $category->getVirtualRule()->getConditions()->getSearchQuery($excludedCategories);
        $parentCategory = $this->getVirtualRootCategory($category);

        if ($parentCategory && in_array($parentCategory->getId(), $excludedCategories)) {
            $query = null;
        } if ($parentCategory && $parentCategory->getId()) {
            $parentQuery = $this->getCategorySearchQuery($parentCategory, $excludedCategories);
            if ($parentQuery) {
                $query = $this->queryFactory->create(QueryInterface::TYPE_BOOL, ['must' => [$query, $parentQuery]]);
            }
        }

        return $query;
    }
private function getVirtualCategoryQuery ( CategoryInterface $ category , $ excludedCategories = [ ] ) { $ query = $ category -> getVirtualRule ( ) -> getConditions ( ) -> getSearchQuery ( $ excludedCategories ) ; $ parentCategory = $ this -> getVirtualRootCategory ( $ category ) ; if ( $ parentCategory && in_array ( $ parentCategory -> getId ( ) , $ excludedCategories ) ) { $ query = null ; } if ( $ parentCategory && $ parentCategory -> getId ( ) ) { $ parentQuery = $ this -> getCategorySearchQuery ( $ parentCategory , $ excludedCategories ) ; if ( $ parentQuery ) { $ query = $ this -> queryFactory -> create ( QueryInterface :: TYPE_BOOL , [ 'must' => [ $ query , $ parentQuery ] ] ) ; } } return $ query ; }
Transform the virtual category into a QueryInterface used for filtering.

@param CategoryInterface $category           Virtual category.
@param array             $excludedCategories Category already used into the building stack. Avoid short circuit.

@return QueryInterface
Transform the virtual category into a QueryInterface used for filtering .