After getting data with curl I create new product and save it:

$product = Mage::getModel('catalog/product');
}catch(Exception $e){

Well for each product it takes about 1.5 sec to save(). That's kinda problem if importing over 1000 products. Digging in Magento core methods, I found that majority of time goes for caching.

So I'd like to know if there's a way to turn off ALL caching during some code execution, later when all products imported, turn back on and reindex the data. Turning off caching from admin panel doesn't fix the time issue.

4 Answers 4


You want as B00MER wrote to stop indexing and set it to manual mode.

Beside this you should think about changing your import behaviour.

Saving catalog/product is slow, because it makes a lot of querys per product. What you want instead is to write multiple data with one query, like the following modules/software do:

  1. https://github.com/magento-hackathon/cutesave
  2. https://github.com/avstudnitz/AvS_FastSimpleImport
  3. https://github.com/dweeves/magmi-git

1.5 seconds IS slow but when you take in to consideration that when a product is saved, observers fire, indexes get updated, caches get invalidated etc you start to understand why.

There are direct to database solutions out there that will speed up product insertion but they all circumvent the Magento stack meaning that code that relies on certain actions happening to function may not get fired. It is just something to consider when deciding to go this route.

As in the solution just posted, the quickest solution is to turn indexing to manual whilst importing and then Auto afterwards making sure you do a full reindex of the catalog.

protected function _getIndexers() 
    return Mage::getSingleton('index/indexer')->getProcessesCollection();   

protected function _stopReindex()
    $this->_getIndexers()->walk('setMode', array(Mage_Index_Model_Process::MODE_MANUAL));

protected function _startReindex()
    $this->_getIndexers()->walk('setMode', array(Mage_Index_Model_Process::MODE_REAL_TIME));

In my opinion the fastest way to import product to magento is magmi script.

You can parse your data to csv file and import them with magmi script. You can run magmi import programically for example with include function - just include magmi/web/magmi_run.php?mode=update&profile=default&engine=magmi_productimportengine:Magmi_ProductImportEngine

If you want to some help please send me private message.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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