Search code examples
magentoindexing

Magento - disable indexer for specific store


I'm using 5 stores only for orders (no frontend, only backend).

Is there a way to disable indexer process (especially catalog_product_flat and catalog_search) for specific store id?


Solution

  • you can't disable it in configuration. it's easy to do for the flat index, you have to update a loop where it creates

    \Mage_Catalog_Model_Product_Indexer_Flat::_processEvent
    

    The next step is:

    \Mage_Catalog_Model_Product_Flat_Indexer
    

    The next step is:

    \Mage_Catalog_Model_Resource_Product_Flat_Indexer
    

    Now one of the main functions (this function calls rebuild function and fill data into the table):

    \Mage_Catalog_Model_Resource_Product_Flat_Indexer::reindexAll
    

    And your final call:

    \Mage_Catalog_Model_Resource_Product_Flat_Indexer::rebuild
    

    There is a loop in the function:

    public function rebuild($store = null)
    {
        if ($store === null) {
            foreach (Mage::app()->getStores() as $store) {
                $this->rebuild($store->getId());
            }
            return $this;
        }
    

    if you update this loop, you can skip the desired store from flat indexer. Location of the function is: app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php:121

    And very similar logic for a FullText search index: \Mage_CatalogSearch_Model_Resource_Fulltext::rebuildIndex