How to reindex data in magento?

We will talk about how to reindex data in magento?

There are different ways we can reindex magento data. I have created three different examples on how to reindex data.

Example 1: reindex data via magento admin panel.

Easiest way is to login magento admin panel, got o “Systems > Index Management” and select all indexs, action to “Reindex Data” and click on submit button.

Example 2: how to reindex data programmatically in magento?.
Magento has different 9 different indexes. If you want to refresh all of them then following code will help you.

for ($i = 0; $i < = 8; $i++) {
    $process = Mage::getModel('index/process')->load($i);

Example 3: Out of the box data reindexing in magento?.
Create a file reindex.php and execute this file on linux command prompt. If you reindex data manually using following script it will resolve the problem like reindex is incomplete or still showing indexing from long time, etc.

PS: Change path for ‘Mage.php’ & “indexer.php” file path in following code according to environment.

require_once '/var/www/html/app/Mage.php';
        //reindex using magento command line
        foreach($idxlist as $idx)
            echo "reindex $idx \n ";
            exec("php /var/www/html/shell/indexer.php --reindex $idx");

Example 4: simple command to reindex in magento?.
If you are very good in linux then go the command prompt and execute following command to reindex data.

php shell/indexer.php reindexall

Let me know if you need more help!.

Share this nice post:

3 thoughts on “How to reindex data in magento?

Comments are closed.