How to Reindex Magento Data Through Command Line?

Magento has feature of index management in admin panel.

Index Management


But some times there will be problem with data indexing when you have a lot of products in database and limited server resource.

Alternatively you can reindex Magento data through command line also.

For Magento 1.9

Step 1 : In Magento root there is folder as name "shell".

Step 2 :  In folder "shell" there is a file with name “indexer.php”, this is shell script for reindexing.

Usage:  php -f indexer.php -- [options]

  --status <indexer>            Show Indexer(s) Status
  --mode <indexer>              Show Indexer(s) Index Mode
  --mode-realtime <indexer>     Set index mode type "Update on Save"
  --mode-manual <indexer>       Set index mode type "Manual Update"
  --reindex <indexer>           Reindex Data
  info                          Show allowed indexers
  reindexall                    Reindex Data by all indexers
  help                          This help

  <indexer>     Comma separated indexer codes or value "all" for all indexers


Step 3 : Have a look for following command to check the current status of all indices is:

php /your-magento-path/shell/indexer.php --status

php /your-magento-path/shell/indexer.php info

To refresh the specific index, you need to select a specific indices to index. This will return results like followings:

catalog_product_attribute Product Attributes
catalog_product_price Product Prices
catalog_url Catalog Url Rewrites
catalog_product_flat Product Flat Data
catalog_category_flat Category Flat Data
catalog_category_product Category Products
catalogsearch_fulltext Catalog Search Index
cataloginventory_stock Stock status

Now, to run indexer on any indices you have to run command like this

php /your-magento-path//shell/indexer.php --reindex catalog_product_price
php /your-magento-path//shell/indexer.php --reindex cataloginventory_stock


For Magento 2

Step 1: Run following command to reindex data of Magento 2.

bin/magento indexer:reindex [indexer]

The command line approach is considered to be little bit faster than admin panel. So, what’s your favorite way of indexing Magento’s data? Please leave me a comment and let me know.

Feel free to ask any help.If you face any problems or need our professional services, please email us at [email protected]


Join our Newsletter

Never miss the latest offers, voucher codes and useful articles delivered weekly in your inbox.