diff --git a/src/module-elasticsuite-virtual-category/Api/Data/VirtualRuleInterface.php b/src/module-elasticsuite-virtual-category/Api/Data/VirtualRuleInterface.php index b438465bf..e921b44e6 100644 --- a/src/module-elasticsuite-virtual-category/Api/Data/VirtualRuleInterface.php +++ b/src/module-elasticsuite-virtual-category/Api/Data/VirtualRuleInterface.php @@ -33,7 +33,7 @@ interface VirtualRuleInterface * * @return \Smile\ElasticsuiteCore\Search\Request\QueryInterface */ - public function getCategorySearchQuery($category, $excludedCategories = []); + public function getCategorySearchQuery($category, &$excludedCategories = []); /** * Retrieve search queries of children categories. diff --git a/src/module-elasticsuite-virtual-category/Model/Rule.php b/src/module-elasticsuite-virtual-category/Model/Rule.php index b502d7c66..4dc4ebd34 100644 --- a/src/module-elasticsuite-virtual-category/Model/Rule.php +++ b/src/module-elasticsuite-virtual-category/Model/Rule.php @@ -144,7 +144,7 @@ public function __toString(): string * * @return QueryInterface|null */ - public function getCategorySearchQuery($category, $excludedCategories = []): ?QueryInterface + public function getCategorySearchQuery($category, &$excludedCategories = []): ?QueryInterface { $query = null; @@ -307,7 +307,7 @@ private function getRootCategory(int $rootCategoryId, int $storeId = null) * * @return QueryInterface */ - private function getStandardCategoryQuery(CategoryInterface $category, $excludedCategories = []): QueryInterface + private function getStandardCategoryQuery(CategoryInterface $category, &$excludedCategories = []): QueryInterface { return $this->getStandardCategoriesQuery([$category->getId()], $excludedCategories); } @@ -320,7 +320,7 @@ private function getStandardCategoryQuery(CategoryInterface $category, $excluded * * @return QueryInterface */ - private function getStandardCategoriesQuery(array $categoryIds, $excludedCategories): QueryInterface + private function getStandardCategoriesQuery(array $categoryIds, &$excludedCategories): QueryInterface { $conditionsParams = ['data' => ['attribute' => 'category_ids', 'operator' => '()', 'value' => $categoryIds]]; $categoryCondition = $this->productConditionsFactory->create($conditionsParams); @@ -338,7 +338,7 @@ private function getStandardCategoriesQuery(array $categoryIds, $excludedCategor */ private function getVirtualCategoryQuery( CategoryInterface $category, - $excludedCategories = [] + &$excludedCategories = [] ): ?QueryInterface { $query = $category->getVirtualRule()->getConditions()->getSearchQuery($excludedCategories); $rootCategory = $this->getVirtualRootCategory($category); @@ -367,7 +367,7 @@ private function getVirtualCategoryQuery( * * @return \Smile\ElasticsuiteCore\Search\Request\QueryInterface */ - private function addChildrenQueries($query, CategoryInterface $category, $excludedCategories = []): QueryInterface + private function addChildrenQueries($query, CategoryInterface $category, &$excludedCategories = []): QueryInterface { $childrenCategories = $this->getChildrenCategories($category, $excludedCategories); $childrenCategoriesIds = []; @@ -406,7 +406,7 @@ private function addChildrenQueries($query, CategoryInterface $category, $exclud * * @return Collection */ - private function getChildrenCategories(CategoryInterface $category, $excludedCategories = []): Collection + private function getChildrenCategories(CategoryInterface $category, &$excludedCategories = []): Collection { $storeId = $category->getStoreId(); $categoryCollection = $this->categoryCollectionFactory->create()->setStoreId($storeId);