Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用datapump api从mysql向magento导入产品的速度非常慢_Php_Mysql_Magento_Magmi - Fatal编程技术网

Php 使用datapump api从mysql向magento导入产品的速度非常慢

Php 使用datapump api从mysql向magento导入产品的速度非常慢,php,mysql,magento,magmi,Php,Mysql,Magento,Magmi,我正在努力让我的脚本工作。我基本上是将数据从CSV导入mysql,效果很好。然后,我喜欢将这些数据与Magmi及其具有正确属性的数据泵API一起导入magento 我的脚本基本上可以正常工作,但它需要大量的时间导入。我认为这是因为每次导入都会再次调用API <?php header('Content-Type: text/html; charset=utf-8'); require_once("/volume1/web/bwebshop/magmi/inc/magmi_defs.php

我正在努力让我的脚本工作。我基本上是将数据从CSV导入mysql,效果很好。然后,我喜欢将这些数据与Magmi及其具有正确属性的数据泵API一起导入magento

我的脚本基本上可以正常工作,但它需要大量的时间导入。我认为这是因为每次导入都会再次调用API

<?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 FROM 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();



}  

您拥有
$dp=Magmi_DataPumpFactory::getDataPumpInstance(“productimport”)
$dp->beginImportSession()
$dp->endImportSession()

每次导入只能调用一次(不是针对每个项目)。尝试将这些移动到项目循环之外

比如:

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