php - product import into magento from mysql with datapump api very slow -


i trying script working. import data csv mysql, works fine. take data , import magmi , datapump api right attributes magento.

my script works takes awful lot of time importing. think because api gets called again every import.

<?php  header('content-type: text/html; charset=utf-8');  require_once("/volume1/web/bwebshop/magmi/inc/magmi_defs.php"); require_once("/volume1/web/bwebshop/magmi/integration/inc/magmi_datapump.php");  $host=""; $user=""; $pw="";  $connection=mysql_connect($host, $user, $pw) or die ("verbindungsversuch fehlgeschlagen");  $mysqldb="xxxxx"; // gewuenschte datenbank angeben  mysql_select_db($mysqldb, $connection) or die("konnte die datenbank nicht waehlen.");   mysql_query('set character set \'utf8\'');  $sql = "select d,q test"; $result = mysql_query($sql);   $list = array();  while ($row = mysql_fetch_array($result)) { $list[] = $row;     $dp=magmi_datapumpfactory::getdatapumpinstance("productimport"); $dp->beginimportsession("categories","create");  $item = array("sku"=> $row['q'], "categories"=> $row['d'], "attribute_set"=> "webshop"));   $dp->ingest($item);  $dp->endimportsession();    }   

i think last 4 rows should somewhere else. doing wrong? appreciated. thanks.

you have $dp=magmi_datapumpfactory::getdatapumpinstance("productimport");, $dp->beginimportsession(); , $dp->endimportsession(); within item loop.

these should called once per import (not each item). try moving these outside of item loop.

something like:

$dp=magmi_datapumpfactory::getdatapumpinstance("productimport"); $dp->beginimportsession("categories","create");  while ($row = mysql_fetch_array($result)) {     $list[] = $row;      $item = array("sku"=> $row['q'], "categories"=> $row['d'], "attribute_set"=> "webshop"));          $dp->ingest($item);     }  $dp->endimportsession(); 

Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -