Skip to content

Commit 7dedee6

Browse files
author
silinmykola
committed
33398 fix is_anchor for disabled categories on global level
1 parent 44a86cb commit 7dedee6

File tree

1 file changed

+9
-3
lines changed
  • app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin

1 file changed

+9
-3
lines changed

app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Category.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,15 @@ private function addCommitCallback(ResourceCategory $resourceCategory, \Closure
4343
$resourceCategory->beginTransaction();
4444
$result = $proceed($category);
4545
$resourceCategory->addCommitCallback(function () use ($category) {
46-
$affectedProducts = $category->getAffectedProductIds();
47-
if (is_array($affectedProducts)) {
48-
$this->reindexList($affectedProducts);
46+
$affectedProductIds = $category->getAffectedProductIds() ?? [];
47+
48+
if ($category->dataHasChangedFor('is_anchor')
49+
|| $category->dataHasChangedFor('is_active')) {
50+
$affectedProductIds = $category->getProductCollection()->getAllIds();
51+
}
52+
53+
if (!empty($affectedProductIds)) {
54+
$this->reindexList($affectedProductIds);
4955
}
5056
});
5157
$resourceCategory->commit();

0 commit comments

Comments
 (0)