-2

I need a Re-indexing programatically in magento

3
  • What's the question? – Robbie Averill Feb 1 '17 at 7:41
  • Sorry for that and now you can see question – K Tech Feb 1 '17 at 7:45
  • Did you search first? There's plenty of these questions already – Robbie Averill Feb 1 '17 at 8:37
1

To reindex all data:

for ($i = 1; $i <= 9; $i++) {
    $process = Mage::getModel('index/process')->load($i);
    $process->reindexAll();
}
1

The following will reindex each index. >

for ($i = 1; $i <= 9; $i++)  
    {  
        $process = Mage::getModel('index/process')->load($i);
    $process->reindexAll();  
    }  

You can also use the Magento collection model to load each index rather than hard coding the id in the for loop.

$indexCollection = Mage::getModel('index/process')->getCollection();
foreach ($indexCollection as $index)  
   {
    /* @var $index Mage_Index_Model_Process */  
    $index->reindexAll();  
}  

You could also call the function getProcessByCode as follows: >

$process = Mage::getModel('index/indexer')->getProcessByCode('catalog_product_price');
$process->reindexAll();
0
$indexingProcesses = Mage::getSingleton('index/indexer')->getProcessesCollection(); 

foreach ($indexingProcesses as $process) {
      $process->reindexEverything();
}
0

I think quickway to do it :

reindexAll() method we can reindex all indexes

Mage::getModel('index/indexer')->reindexAll();

Not the answer you're looking for? Browse other questions tagged or ask your own question.