How to reindex Magento Data Programmatically

Hello, In magento, You can manually reindex data from System -> Index Management. But if you get any problem in indexing then you can do it through code/programming. Currently, there are 9 indexes. They are as give n below: (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 only “Category Products” index, then you can use the code given
$process = Mage::getModel('index/process')->load(6);
$process->reindexAll();
below:- If you want to reindex all indexes, then you can loop through these indices to reindex them.
for ($i = 1; $i <= 9; $i++) {
    $process = Mage::getModel('index/process')->load($i);
    $process->reindexAll();
}
Check the code given below:- Thanks,
Pritesh Pritesh

Pritesh Pethani

Request a Quote!!

Share your concept and we will return to you within 24 hours. Let us work out the best software solution for you!

Let's Start
Whatspp