Home » Magento1 November 2011

Magento: Reindex Data Programmatically

This article shows how to reindex Magento Data Programmatically (through code).

You can manually reindex data from System -> Index Management. However, this article is concerned how this can be done through code/programming.

Currently, there are 9 indexes. They are as under (with their respective key number):-

1. Product Attributes
2. Product Prices
3. Catalog URL Rewrites
4. Product Flat Data
5. Category Flat Data
6. Category Products
7. Catalog Search index
8. Tag Aggregation Data
9. Stock Status

So, if you want to reindex “Category Products” only then you can do as follows:-

If you want to reindex all data then you can loop through these indices and then reindex them:-

Hope this helps. Thanks.

Magento

Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed
  • MagentoDev

    Thanks

  • Fabian Blechschmidt

    Thanks for this tip!

    But we should load not all processes by hand:
    getCollection();

    foreach ($processCollection as $process) {
    /* @var $process Mage_Index_Model_Process */
    $process->reindexAll();
    }

    This way, we don’t need to hope, that the IDs didn’t change

  • Fabian Blechschmidt

    This should be $process = Mage::getModel(‘index/process’)->getCollection();