Monday, 14 November 2011

Magento Indexing through command line - ssh

It is normal that Magento indexing takes long time or issue with browser memory limit or connection time-out. So you can try the command line alternative through the SSH connection of the website.

Way 1:

Go to yoursite/public_html/


$ cd shell

php indexer.php                   - Displays help information on how to use the script
php indexer.php --status          - Shows the status of all the indexes
php indexer.php info              - Shows the "codes" for the individual indexes
php indexer.php --reindex   - Re-indexes the index
php indexer.php reindexall        - Re-indexes all the indexes

This also output the valuable error if indexing fails with any reason.

Way 2.

Create a file named "indexing.php" with following code.

// Code ends

require_once './app/Mage.php';

umask( 0 );
Mage :: app( "default" );

if(defined('STDIN') )
echo("Running from CLI \n");
$processNo=isset($argv[1])?$argv[1] : 1;
echo("Running through Browser
$processNo=(isset($_GET['process']))? $_GET['process'] : 1 ;

echo "\n
Started Indexing At:  " . date("d/m/y h:i:s");
$process = Mage::getModel('index/process')->load($processNo);
echo "\n
Indexing Completes At: ".date("d/m/y h:i:s");
// Code ends

Now you can run this file through browser with url below:


run it through ssh (RECOMMENDED)

php indexing.php 1

//assume that your working directing is public_html where magento resides.

// List of Process No.

1    Product Attributes       Index product attributes for layered navigation building
2    Product Prices           Index product prices
3    Catalog URL Rewrites     Index product and categories URL rewrites
4    Product Flat Data        Reorganize EAV product structure to flat structure
5    Category Flat Data       Reorganize EAV category structure to flat structure
6    Category Products        Indexed category/products association
7    Catalog Search Index    Rebuild Catalog product fulltext
8    Stock Status             Index Product Stock Status
9    Tag Aggregation Data     Rebuild Tag aggregation data


  1. Super-Duper site! I am loving it!! Will come back again. I am bookmarking your feeds also

  2. awesome blog! i liked your way of description.

  3. I simply desired to thank you very much again. I'm not certain the things I would have undertaken in the absence of the recommendations documented by you regarding such a question. This was a real frightening issue in my position, nevertheless understanding a expert manner you dealt with the issue made me to cry with happiness. I'm grateful for the guidance and trust you really know what a great job you happen to be getting into educating the rest through the use of your webpage. I know that you haven't got to know any of us.

  4. good post. thank for sharing.

  5. Hello. Thanks, it's very useful and important information. We have an article on the similar topic posted here you're welcome to check it out and leave your feedback.

  6. We have just released a little patch that optimizes time processing when "Catalog Url Rewrites" is launched.

    For example:

    With 9500 references (SKU), shared (or not) between 900 categories / Sub-categories and with CMS pages, the number of generated URLs in the «Core_URL_Rewrite» table is about 80 000.

    The re-index (launched manually or by CRON) lasts about 3h30.

    After installing this patch, the re-index duration is about 1 minute!

    Full article & Benchmark available @

  7. You have brought up a very superb points , thanks for the post.

  8. Great Read! I am impressed on how you make your article easy to understand. I'll come back for more :D

    Japs Buidon is a Social Media Specialist and belongs to a team of Magento Developer in Florida. He loves hiking as well as electronics.