Magento – completely disable an indexer

cataloginventoryconfigurationindexerindexingmagento-1

I have a situation where I'd like to completely disable one of Magento's core indexers (cataloginventory_stock). I don't want this index to ever be rebuilt, maintained or altered in any way.

Is it possible to disable or "unregister" an indexer?

Things I've tried:

  1. See if there's a way to disable it via config xml (there isn't).
  2. Look for events around config xml loading that might permit me to remove the indexer's definition in XML before it can be used. There isn't, and that's logical as until the XML is loaded there's no way to define event observers!

What does seem to work is to rewrite the Mage_CatalogInventory_Model_Indexer_Stock class and replace most of it's methods with versions that either return false (matchEvent and matchEntityAndType) or are otherwise NoOps. While this works, it doesn't seem like a particularly elegant solution. Is there a better way?

Please Note: I am aware that there will be many flow on effects from disabling this particular indexer, and I've dealt with most of them already.

Best Answer

I was struggling with the same issue, and got a clean solution to it.

Mage_Index_Model_Indexer_Abstract has an inbuilt function called isVisible()

If this function returns false, then the indexer is disabled completely.

So you can extend class Mage_CatalogInventory_Model_Indexer_Stock and then add isVisible() function to it which returns false (hardcode / by a config entry for enable/disable), which will hide / disable the indexer.

You can also refer Mage_Catalog_Model_Category_Indexer_Flat, this indexer uses the same concept.

Hope this solutions helps someone

Related Topic