-
Notifications
You must be signed in to change notification settings - Fork 341
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
Fixes #1937 preventing displaying all products from catalog on deleted virtual category #2007
base: 2.9.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,15 +139,21 @@ public function __toString(): string | |
public function getCategorySearchQuery($category, $excludedCategories = []): ?QueryInterface | ||
{ | ||
$query = null; | ||
$rootCategory = null; | ||
|
||
if (!is_object($category)) { | ||
$category = $this->categoryFactory->create()->setStoreId($this->getStoreId())->load($category); | ||
} | ||
|
||
if (!in_array($category->getId(), $excludedCategories)) { | ||
$excludedCategories[] = $category->getId(); | ||
|
||
if ((bool) $category->getIsVirtualCategory() && $category->getIsActive()) { | ||
if ($category->getIsVirtualCategory() && $category->getVirtualCategoryRoot() !== null | ||
&& !empty($category->getVirtualCategoryRoot())) { | ||
$rootCategoryId = $category->getVirtualCategoryRoot(); | ||
$rootCategory = $this->categoryFactory->create()->setStoreId($this->getStoreId())->load($rootCategoryId); | ||
$catId = $rootCategory->getId(); | ||
} | ||
if ((bool) $category->getIsVirtualCategory() && $category->getIsActive() && isset($catId)) { | ||
Comment on lines
+150
to
+156
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a fan of the approach since it integrates part of the logic of checking the existence of the root category in \Smile\ElasticsuiteVirtualCategory\Model\Rule::getVirtualRootCategory.
But it's not perfect, and still a bit more complex. On an additional note, your fix will apply when visiting the virtual category, but won't have any effect on parent categories, so we might want to address the problem as a whole by looking at what would happen in \Smile\ElasticsuiteVirtualCategory\Model\Rule::addChildrenQueries There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Conclusion: we need to discuss this. |
||
$query = $this->getVirtualCategoryQuery($category, $excludedCategories, $category->getData('virtual_category_root')); | ||
} elseif ($category->getId() && $category->getIsActive()) { | ||
$query = $this->getStandardCategoryQuery($category, $excludedCategories); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't a reason to initialize that variable since it is systematically overwritten in your additional condition.