Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass excluded categories by reference #1963

Open
wants to merge 4 commits into
base: 2.10.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 6 additions & 6 deletions src/module-elasticsuite-virtual-category/Model/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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);
Expand Down