I am working on a custom module where I want to upload a csv file in the admin backend. The csv would have a minimum of 150000 entries and it is right now taking more than 2 hours to complete the import

  • better to go with the magmi ? – Baby in Magento Dec 30 '16 at 7:54
  • There isn't much you can do, objects are rather big in Magento. If we're talking products then 150k is quite a big number. Unless you want to manually query the DB it won't be any faster. – Julien Lachal Dec 30 '16 at 7:55
  • you can use direct sql query using transaction object, rollback. – sandip Dec 30 '16 at 8:02

direct SQL queries is the only option, ugly but fast (refer to magmi project for implementation)

sample code:

$file = 'file.csv';
$csv = new Varien_File_Csv();
$data = $csv->getData($csv);
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
foreach($data as $row){
  $value1 = $row[1];
  $write->query("INSERT INTO table(value1) VALUES('{$value1}')");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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