I'm trying to reindex one product only programmatically:

$product = Mage::getModel('catalog/product')->load($_productId);

However, nothing is inserted to cataloginventory_stock_status_idx table. But if I reindex using command line:

php indexer.php --reindex cataloginventory_stock

The table is populated.

2 Answers 2


You should try with:

Mage::getModel('catalogsearch/fulltext')->getResource()->rebuildIndex( 1, (int)$product->getId());


$process = Mage::getSingleton('index/indexer')->getProcessByCode($code);

Or if you want to do Mage::getSingleton('index/indexer')->processEntityAction your event needs to be registered and processed like in: app/code/core/Mage/CatalogInventory/Model/Indexer/Stock.php

protected function _registerEvent(Mage_Index_Model_Event $event)

which already has case Mage_CatalogInventory_Model_Stock_Item::ENTITY

you just need to add something like: $event->addNewData('cataloginventory_stock_reindex_all', true); to that case

and method

protected function _processEvent(Mage_Index_Model_Event $event)

already has:

if (!empty($data['cataloginventory_stock_reindex_all'])) {

Don't forget to extend this and don't write code in core.

  • Doesn't $process->reindexAll(); will reindexall? How about for a single item only? Commented May 8, 2015 at 0:29
  • @user1240207 take a look over this but I don't think single product reindex is available in newer magento versions.
    – Magarusu
    Commented May 13, 2015 at 10:55
  • Some indexers have methods that will reindex by product id. Ex: Mage::getSingleton('catalog/url')->refreshProductRewrite($productId); Mage::getSingleton('catalogsearch/fulltext')->rebuildIndex(null, $productId);
    – Magarusu
    Commented May 18, 2015 at 9:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.