reindexing magento programmatically.Magento re-index data by SSH or by script.
reindexing magento programmatically.Magento re-index data by SSH or by script

Good way to re-index data in magento without admin panel is SSH.Also I have been locked in admin panel and unable to reindex all data the SSH is the good practice to do.Sometime if we don’t have access to SSH then we can do Reindexing magento programmatically.So please follow details instruction at first I have explained in the way of SSH and latter I have explained how we can managed through script or Programmatically.So lets see how to Manage magento re-index data by SSH or by programmatically.

SSH Instruction:

1: First you can login into your SSH connection and then go to shell folder of magento installation.

2: Then get full list of magento indexer command.

Out put will be like :

3: Then do reindex data by.

4: If you like to reindex for some specific process then first check all reindex code available in magento.Basicall by default there are 9 reindex code present in magento.

Out put will be like :

5: so finally you can do your reindex process one by one if you like to do for specific process.

Programmatically instructions:

Generally by default magento provides 9 index processes. You can see the above result which I have shown the output from SSH command or you can see in index_process table.If you would like to update programmatically the use the indexer process codes which I have explained individually.

  1. catalog_product_attribute : Product Attributes (If you updated attributes which are used layered navigation)
  2. catalog_product_price : Product Prices (If you updated prices)
  3. catalog_url : Catalog URL Rewrites (If you updated Product or Catalag url)
  4. catalog_product_flat : Product Flat Data (If in your store you have used Flat tables and you updated product attributes which are used frontend logic)
  5. catalog_category_flat : Category Flat Data (If you updated category attributes)
  6. catalog_category_product : Category Products (If you added or removed products from catalog)
  7. catalogsearch_fulltext : Catalog Search Index (If you updated searchable attributes of product)
  8. cataloginventory_stock : Stock Status (If you updated stock options of product)
  9. tag_summary : Tag Aggregation Data (If you updated Product tag)

So lets start our coding part:

first you have to fetch the indexer model by Mage::getModel(‘index/indexer’) and use above code in the function getProcessByCode() as parameters.So finale code will be


For Product Attributes:

For Product Prices:

For Catalog URL Rewrites:

For Product Flat Data:

For Category Flat Data:

For Category Products:

For Catalog Search Index:

For Stock Status:

For Tag Aggregation Data:

Also if you would like to refresh all at once then use the following code.

And also after doing everything flush all the cache to get better result by .

Final script:

Reindexing in magento programmatically
Tagged on:                                         

One thought on “Reindexing in magento programmatically

  • September 21, 2016 at 1:42 am

    This rebuilds the whole table. Is there a way to just update the entries in index_event table?

    How would you write a shell script to just process the index_event table?


Leave a Reply

Your email address will not be published.