I am trying to re-index product prices after update in my product price but its not working showing me old price in product list page.I am using this code

$process = Mage::getModel('index/indexer')->getProcessByCode('catalog_product_price');

i also tried this one

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

But its not working. I have tried from by this command

php indexer.php --reindex catalog_product_price

Its working fine showing me updated prices.

  • What does $reindex contain? Are you sure it is loaded? Dec 7 '16 at 14:43
  • yeah 2 is the id of this process catalog_product_price
    – OBAID
    Dec 7 '16 at 14:58
  • I know, but I asked it you are sure $reindex is a loaded object or not. Try echoing echo $reindex->getStatus() and see it if works. Dec 7 '16 at 15:01
  • string(7) "pending" getting this
    – OBAID
    Dec 7 '16 at 15:07
  • Have you tried running $reindex->reindexEverything() ? Dec 7 '16 at 15:09

Create external file test.php in magento root. Please add below code in it.

include 'app/Mage.php';

// clear cache

// reindex prices
1 = Product Attributes
2 = Product Attributes
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

// Recreate a single index programmatically
Mage::getModel('index/process')->load(Mage_Catalog_Helper_Product_Flat::CATALOG_FLAT_PROCESS_CODE, 'indexer_code')->reindexEverything();

The right function to call is:


Just add it in an observer.


You could build a custom script to run * * * * * /usr/bin/php /path/to/indexer.php --reindex catalog_product_price as a crontab (if you're using Linux).

It's not a magento solution, but it would work if it's something that's mission critical. Where you could have it run on a regular interval? Not the best solution, but it might be what you're looking for.

  • The OP wants to do it programmatically, not using the command line. Dec 8 '16 at 8:00
  • How is that not programmatically? Dec 8 '16 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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