private getCategorySearchQuery ( array $excludedCategories ) : Smile\ElasticsuiteCore\Search\Request\QueryInterface | ||
$excludedCategories | array | Category excluded from the loading (avoid infinite loop in query building when circular references are present). |
return | Smile\ElasticsuiteCore\Search\Request\QueryInterface |
private function getCategorySearchQuery($excludedCategories)
{
$categoryIds = array_diff(explode(',', $this->getValue()), $excludedCategories);
$subQueries = [];
foreach ($categoryIds as $categoryId) {
$subQueries[] = $this->getRule()->getCategorySearchQuery($categoryId, $excludedCategories);
}
$query = $this->queryFactory->create(QueryInterface::TYPE_BOOL, ['should' => $subQueries]);
if (count($subQueries) === 1) {
$query = current($subQueries);
}
return $query;
}