Mark index as invalid or invalidate index in Magento 2

To programmatically mark on of the indexes as invalid you need help of

\Magento\Framework\Indexer\IndexerRegistry

. After receiving the indexer instance, you can call

invalidate()

method.

Example

$this->indexerRegistry->get(\Magento\CatalogSearch\Model\Indexer\Fulltext::INDEXER_ID)->invalidate();
Share
2021   index   indexer   magento 2