Re-indexing Magento through the command line

  • 0
  • December 5, 2013

From time to time, you might find the need to re-index Magento via the command line. This could be for a whole host of reasons, for example, if the indexer is timing out or not finishing through the web interface.

Magento includes an indexing script and you can find it in the shell folder.

From here, you have a number of commands at your disposal.

Checking for the status of all indexes

php indexer.php --status

Should give you output like this:

Re-indexing a single index

Each index has its own index key that you can use to reference it when asking Magento to re-index. To get these keys, you can use the following command:

php indexer.php --info

Giving you:

To reindex a single index, run the following command.

php indexer.php --reindex [Index Option Code]

This can be comma delimited for multiple indices:

php indexer.php --reindex catalog_product_price,catalog_url,catalog_product_flat

Re-index all indices

The following code will loop through each index and re-index it.

php indexer.php --reindexall

Douglas Radburn

About Douglas Radburn

As our Head of Technical Doug has played a key role within the Development team since 2009. A founding developer of our Twitition and Competwition platforms, Doug has also been lead in our Open Source Projects on Magento ecommerce solutions and Wordpress CMS platforms.

  • DiseƱo Paginas Web

    thanks, good post, it happends to me that after an upgrade from 1.5 to 1.7 it was just imposible to reindex, this is a good solution I was not aware of

  • Joe Harman

    We are running our Magento webservers on AWS. Magento is running a multisite setup.

    Load Balancer Connected to 4 Apache Webservers, 1 MySQL database running Percona MySQL

    When using php indexer.php –reindexall and monitoring the incoming queries to MySQL I noticed that my queries were originating from all 4 of the webservers, even though I only started the indexing process on 1 of the webservers.

    Do you know how isolate the indexing process to only the server it is initiated on? Have you found any performance differences in running these as comma delimited (php indexer.php –reindex catalog_product_price,catalog_url,catalog_product_flat)?

  • Robbz

    Is there a way to stop and restart the indexing? I discovered some time ago, that when i start the indexer, a few seconds later it quits, without any output. Also nothing happened. When i checked the status, it says “running”, but it does absolutely nothing.

    Are there any ideas how to solve this?

    ps: I’m using solrgento to redinex the “catalogsearch_fulltext”

Like what you see? Talk to an Expert