Magento – Order of Indexing

ee-1.11indexingmagento-enterprise

Can someone please tell me is there any specific order for indexing needs to follow. My current order is,

  1. catalog_product_attribute
  2. catalog_product_price
  3. catalog_url
  4. catalog_product_flat
  5. catalog_category_flat
  6. catalog_category_product
  7. catalogsearch_fulltext
  8. cataloginventory_stock

Why i am asking is since the catalog_url runs as the third and it takes a lot of time to complete. I need to bring up both catalog_product_flat and catalog_category_flat which is required to be upto date for my product import to run correctly.

Thanks 🙂

Best Answer

The indexing order when reindexing all processes is defined by Mage_Index_Model_Indexer::_runAll().
This method uses the depends property of each process to check which other processes have to run before itself can do it's work.

The getDepends() method of the index/process uses the configuration node global/index/indexer/[process-code]/depends to determine it's dependencies.

Having a look at Mage/Catalog/etc/config.xml, the indexer processes configurations there are as follows:

    <index>
        <indexer>
            <catalog_product_attribute>
                <model>catalog/product_indexer_eav</model>
            </catalog_product_attribute>
            <catalog_product_price>
                <model>catalog/product_indexer_price</model>
            </catalog_product_price>
            <catalog_url>
                <model>catalog/indexer_url</model>
            </catalog_url>
            <catalog_product_flat>
                <model>catalog/product_indexer_flat</model>
            </catalog_product_flat>
            <catalog_category_flat>
                <model>catalog/category_indexer_flat</model>
            </catalog_category_flat>
            <catalog_category_product>
                <model>catalog/category_indexer_product</model>
            </catalog_category_product>
        </indexer>
    </index>

No dependencies are declared at all, so I would say the concrete processing order is more or less random, or unspecified.

To have the *_flat indexer processes run before the catalog_url reindexing, it should be enough to add a dependency as follows:

            <catalog_url>
                <model>catalog/indexer_url</model>
                <depends>
                    <catalog_product_flat/>
                    <catalog_category_flat/>
                </depends>
            </catalog_url>