Sometimes you find that after importing a group of products they fail to show up on the frontend of the website, this can be for a number of reasons, but for the most-part you will have noticed that simply opening the product up, and re-saving sorts it out.

What you might not have realised is that re-indexing your catalog will also work in most cases.

If you are importing via the PHP and Mage(), why not try the following snippet:

$process_setting = Mage::getSingleton(‘index/indexer’)->getProcessesCollection();
$proces_setting->walk(‘setMode’, array(Mage_Index_Model_Process::MODE_MANUAL));
$proces_setting->walk(‘save’);

//product imports here

$process = Mage::getModel(‘index/indexer’)->getProcessById(4);
$process->reindexAll();
$process = Mage::getModel(‘index/indexer’)->getProcessById(5);
$process->reindexAll();

$process_setting->walk(‘setMode’, array(Mage_Index_Model_Process::MODE_REAL_TIME));
$process_setting->walk(‘save’);

What does this do?

Basically, the first 3 lines set magento’s indexing processes to manual, so that our product import doesn’t trigger a re-index on every entry (which would slow down any import process).

Next, you run your import code.

Finally, you re-index the flat catalog indexes (id 4 and 5), and re-set the indexing processes to automatic/real time.

Magento 2.4.7 is here!
E-commerce
David Pratt

Magento 2.4.7 Has Arrived!

Magento 2.4.7 is set to land, with the latest release due to be launched on Tuesday the 9th of April 2024. The latest updates sees over 150 performance and security fixes as well as platform enhancements and upgrades.
Read More »
DTF Digital