Skip to content

Commit

Permalink
Only reindex pages if they are searchable or were searchable before.
Browse files Browse the repository at this point in the history
  • Loading branch information
romainruaud committed Jun 5, 2024
1 parent f25e3c8 commit 9e03498
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Plugin/Indexer/Page/Save/ReindexPageAfterSave.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9e03498

Please sign in to comment.