How to Solve Reindexing Issue for Large Catalog in Magento
- Digital Engineering
How to Solve Reindexing Issue for Large Catalog in Magento
When we have large no. of products in our catalog, we generally found a problem that when we do any changes from the admin panel or we use catalog import process to import the products, We see “No Products Matching This Selection” message on category pages at front end while that category has products and everything is fine in the admin panel to display the products on the frontend.
Cause of the problem:
This problem occur because magento does reindexing automatically when we import the products or do any changes in the admin panel on catalog because by default Indexing mode is set to “Update on Save”.
Solution:
One solution to this problem is set indexing mode to Manual from backend.You can change the indexing mode from
System->Index Management
Select all the Indexes and change the index mode to Manual Update from the drop down available at the top right corner of the grid.
But this solution does not fix the problem completely. Because It will not fix the problem of product importing process. It will only fix the problem of backend changes.
To resolve the issue completely,
1. Rewrite startAction() method of following controller
app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php
In this function’s try block add the following code in the beginning
$processes->walk(‘setMode’, array(Mage_Index_Model_Process::MODE_MANUAL));
$processes->walk(‘save’);
So your code should be like this
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
$resultBlock = $this->getLayout()->getBlock('import.frame.result'); $importModel = Mage::getModel('importexport/import'); try { $processes = Mage::getSingleton('index/indexer')->getProcessesCollection(); $processes->walk('setMode', array(Mage_Index_Model_Process::MODE_MANUAL)); $processes->walk('save'); $importModel->importSource(); $importModel->invalidateIndex(); $resultBlock->addAction('show', 'import_validation_container') ->addAction('innerHTML', 'import_validation_container_header', $this->__('Status')); } catch (Exception $e) { $resultBlock->addError($e->getMessage()); $this->renderLayout(); return; } |
2. Copy app/code/core/Mage/CatalogRule/Model/Rule.php in the local directory.
find applyAllRulesToProduct() function on approx 280 line.
Comment below 3 lines of this function
1 2 3 4 |
$indexProcess =Mage::getSingleton('index/indexer')->getProcessByCode('catalog_product_price'); if ($indexProcess) { $indexProcess->reindexAll(); } |
So now code should be like
1 2 3 4 |
//$indexProcess =Mage::getSingleton('index/indexer')->getProcessByCode('catalog_product_price'); // if ($indexProcess) { // $indexProcess->reindexAll(); // } |
Hope this will solve your problem.