diff --git a/Plugin/Indexer/Page/Save/ReindexPageAfterSave.php b/Plugin/Indexer/Page/Save/ReindexPageAfterSave.php index 659c145..7563c3f 100644 --- a/Plugin/Indexer/Page/Save/ReindexPageAfterSave.php +++ b/Plugin/Indexer/Page/Save/ReindexPageAfterSave.php @@ -55,9 +55,13 @@ public function afterSave( \Magento\Framework\Model\ResourceModel\Db\AbstractDb $result, \Magento\Framework\Model\AbstractModel $page ) { - $cmsPageIndexer = $this->indexerRegistry->get(Fulltext::INDEXER_ID); - if (!$cmsPageIndexer->isScheduled()) { - $cmsPageIndexer->reindexRow($page->getId()); + $isSearchable = $page->getIsSearchable(); + $wasSearchable = ($page->dataHasChangedFor('is_searchable') && (int) $page->getOrigData('is_searchable') === 1); + if ($isSearchable || $wasSearchable) { + $cmsPageIndexer = $this->indexerRegistry->get(Fulltext::INDEXER_ID); + if (!$cmsPageIndexer->isScheduled()) { + $cmsPageIndexer->reindexRow($page->getId()); + } } return $result;