diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Category.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Category.php index 1218e3da9a783..1ee14f3fdcabc 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Category.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Category.php @@ -43,9 +43,15 @@ private function addCommitCallback(ResourceCategory $resourceCategory, \Closure $resourceCategory->beginTransaction(); $result = $proceed($category); $resourceCategory->addCommitCallback(function () use ($category) { - $affectedProducts = $category->getAffectedProductIds(); - if (is_array($affectedProducts)) { - $this->reindexList($affectedProducts); + $affectedProductIds = $category->getAffectedProductIds() ?? []; + + if ($category->dataHasChangedFor('is_anchor') + || $category->dataHasChangedFor('is_active')) { + $affectedProductIds = $category->getProductCollection()->getAllIds(); + } + + if (!empty($affectedProductIds)) { + $this->reindexList($affectedProductIds); } }); $resourceCategory->commit();