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):
- Product Attributes
- Product Prices
- Catalog URL Rewrites
- Product Flat Data
- Category Flat Data
- Category Products
- Catalog Search index
- Tag Aggregation Data
- Stock Status
$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 Pethani