Executing Magento Indexer From ShellTheWebsiteGuy
Some times when Magento has a very large catalog you will need to rebuild the indexes from shell / SSH. Executing the Magento Indexer From Shell is fairly straight forward and I personally use Putty as my SSH client.
Once connected to your server via SSH navigate to the shell directory within your Magento install.
[root@159 ~]# cd var/www/vhosts/******/public_html/shell/ [root@159 shell]#
This next command will show the help options for the Magento Indexer from the “indexer.php” script, you will need to execute “php -f indexer.php help” and you will see the following result.
[root@159 shell]# php -f indexer.php help 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 [root@159 shell]#
You can see from the results returned a list of the commands that the indexer will run, I would never recommend to run “reindexall” as this will rebuild all the indexes at the same time, and this can cause excessive MySQL/Server load. Reindexall processes 9 indexers in a row and can lead to database LOCK on some database tables.
I would highly recommend that you run the indexer one by one which will help maintain your websites/servers stability.
Magento has 9 indexers, you can get list of indexers if you call next command “php -f indexer.php info”
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 tag_summary Tag Aggregation Data
If you want to process a single indexer from shell for example “tag_summary” the command for Executing Magento Indexer would be;
php -f indexer.php -- -reindex tag_summary
Once an indexer has successfully completed its process it will return the following status;
[root@159 shell]# php -f indexer.php -- -reindex tag_summary Tag Aggregation Data index was rebuilt successfully [root@159 shell]#