Magento reindex: How to use command line and what to do if reindex is not working

What is reindex and what is it used for?

The platform’s architecture is very complicated, which stems from the necessity to keep multiple merchant data, such as catalog data, prices, customers, stores, etc. All the information is stored in special database tables. To enhance Magento efficiency the data is gathered into the tables using indexers.

As long as the data changes, it should be updated or reindexed (e.g.: having changed the price of a product item from $5.99 to $4.99, the change should be reindexed by Magento to display it on the eStore). In case one or more indexers are set to be updated, you’ll see a message banner.

How to reindex data?

!Reindexing is a background process, which means the store will be usable during the managing!

Magento reindex through the Admin Panel:

  • log into the Admin Panel as an administrator:

magento-admin-panel-log-in

  • go to System>Index Management menu

magento-admin-panel-dashboard

magento-admin-panel-index-management

  • the page contains a set of indexes with their description, mode, status, and other details:

magento-admin-panel-items

  • being notified return to System>Index Management menu;
  • if one index needs updating, choose Reindex Data on the right side or tick the point for further re-indexation and push the ‘Submit’ button:

magento-admin-panel-reindex-required

  • As long as the process is finished, the indexes are brought up to date. 

!However, in some cases you may need to manage reindex thought the command line (e.g: the indexer is timing out or not finish through the web interface)!

Magento reindex through the command line:

  • Connect to the Magento server as a file system owner:
  • An indexing script you need is in the Magento reindex shell folder with a number of commands at your service:

magento-reindex-shell-folder

  • All the indexes should have a correct status: 
php indexer.php --status

either ‘Pending’ or ‘Require Reindex’.

magento-pending-reindex

  • To find a valid index key to refer to during the Magento reindexing process use the following command: 
php indexer.php --info:
php-indexer-magento


To see the whole set of indexers, type: magento indexer: info.

  • Use 

php indexer.php --reindex [Index Option Code]
to reindex a single index.

  • For numerous indexes it can be comma delimited: 

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

  • If you need to reindex each index separately, the next code will do here: 

php indexer.php --reindexall

  • If you are about to reindex the Catalog URLs, use the next command: 

php -f indexer.php -- -reindex catalog_url

  • But all the mentioned commands allow for once-off reindexing only. To have the indexes updated constantly, a cron job should be set up via the Admin Panel of your server. It guarantees data indexation by schedule: 

magento-add-new-cron-job

  • If you need the noticed indexes to be updated in a real-time regime, the default ‘update on save’ mode is to be run. 

Magento reindex not working?

Though, the process is man-sized for nontechnical specialist and can be interrupted or ended off due to the basic glitches:

  • php memory limit

This means the allowed memory size is exhausted. By adding: ini_set (‘memory_limit, ‘ENTER MEMORY VALUE HERE’), e.g.: ini_set (‘memory_limit, ‘1024M’) to the beginning of script you can overcome it:

magento-memory-limit

  • Magento reindex ssh/putty

Getting to your root folder for reindexing via Magento reindex ssh you’ll face a problem with indexer.php finding error because indexer.php is contained under the shell directory.  

Rate the answer?