private function getCategorySearchQuery($excludedCategories)
    {
        $categoryIds = array_diff(explode(',', $this->getValue()), $excludedCategories);
        $subQueries  = [];

        foreach ($categoryIds as $categoryId) {
            $subQuery = $this->getRule()->getCategorySearchQuery($categoryId, $excludedCategories);
            if ($subQuery !== null) {
                $subQueries[] = $subQuery;
            }
        }

        $query = null;

        if (count($subQueries) === 1) {
            $query = current($subQueries);
        } elseif (count($subQueries) > 1) {
            $query = $this->queryFactory->create(QueryInterface::TYPE_BOOL, ['should' => $subQueries]);
        }

        return $query;
    }
private function getCategorySearchQuery($excludedCategories)
    {
        $categoryIds = array_diff(explode(',', $this->getValue()), $excludedCategories);
        $subQueries  = [];

        foreach ($categoryIds as $categoryId) {
            $subQuery = $this->getRule()->getCategorySearchQuery($categoryId, $excludedCategories);
            if ($subQuery !== null) {
                $subQueries[] = $subQuery;
            }
        }

        $query = null;

        if (count($subQueries) === 1) {
            $query = current($subQueries);
        } elseif (count($subQueries) > 1) {
            $query = $this->queryFactory->create(QueryInterface::TYPE_BOOL, ['should' => $subQueries]);
        }

        return $query;
    }
private function getCategorySearchQuery ( $ excludedCategories ) { $ categoryIds = array_diff ( explode ( ',' , $ this -> getValue ( ) ) , $ excludedCategories ) ; $ subQueries = [ ] ; foreach ( $ categoryIds as $ categoryId ) { $ subQuery = $ this -> getRule ( ) -> getCategorySearchQuery ( $ categoryId , $ excludedCategories ) ; if ( $ subQuery !== null ) { $ subQueries [ ] = $ subQuery ; } } $ query = null ; if ( count ( $ subQueries ) === 1 ) { $ query = current ( $ subQueries ) ; } elseif ( count ( $ subQueries ) > 1 ) { $ query = $ this -> queryFactory -> create ( QueryInterface :: TYPE_BOOL , [ 'should' => $ subQueries ] ) ; } return $ query ; }
Retrieve a query used to apply category filter rule.

@param array $excludedCategories Category excluded from the loading (avoid infinite loop in query
building when circular references are present).

@return QueryInterface
Retrieve a query used to apply category filter rule .