How Can I Reindex A Magento Index Programmatically

How can I reindex a Magento index programmatically, like what I did via command line – php indexer.php –reindex catalog_product_price

You need to use model – “index/process” and load the index by ID, then call “reindexAll” function


$process = Mage::getModel('index/process')->load(2);

// 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_stock
// 8 - cataloginventory_stock
// 9 - tag_summary

$process->reindexAll();
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments