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));

//product imports here

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

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

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.

DTF Digital