Php magento xml导入映射
我想将xml类别映射到我的magento类别 我把导入脚本放在一起工作,但它不会导入到magento中的任何类别中 在脚本im测试中,我想导入具有xml格式的产品Php magento xml导入映射,php,xml,magento,Php,Xml,Magento,我想将xml类别映射到我的magento类别 我把导入脚本放在一起工作,但它不会导入到magento中的任何类别中 在脚本im测试中,我想导入具有xml格式的产品 <izdelekKategorija>Komponente</izdelekKategorija> Komponente 进入magento分类号738 我在寻求帮助,我是PHP的初学者 多谢各位 <?php $kat = array( 'Komponente' => '738', );
<izdelekKategorija>Komponente</izdelekKategorija>
Komponente
进入magento分类号738
我在寻求帮助,我是PHP的初学者
多谢各位
<?php
$kat = array(
'Komponente' => '738',
);
class TestLogger
{
/**
* logging methos
*
* @param string $data
* : log content
* @param string $type
* : log type
*/
public function log($data, $type)
{
echo "$type:$data\n";
}
}
// setup include PATH's
set_include_path('magmi' . PATH_SEPARATOR . 'magmi/inc' . PATH_SEPARATOR . 'magmi/integration/inc' . PATH_SEPARATOR . 'magmi/engines');
// end include PATH's
require_once("magmi_datapump.php"); // call Datapump
$dp=Magmi_DataPumpFactory::getDataPumpInstance("productimport");
$dp->beginImportSession("123", "create", new TestLogger()); // default- name of profile , create - we want to create and update items
$file="test.xml";
$microline = new SimpleXMLElement($file, null, true); // load XML
$izdelek = array ((string)$item->izdelekKategorija);
global $kat;
$izdelek = array ((string)$item->izdelekKategorija);
$kategorija = (isset($kat[$izdelek]) ? $kat[$izdelek] : $kategorija);
foreach ($microline as $item){
$newProductData = array(
"sku" => (string)$item->izdelekID .=' inbbt',
"name" => (string)$item->izdelekIme, // name
"attribute_set" => "test", // attribute_set
"store" => "test",
"category_ids" => $kategorija,
"tax_class_id" => "3",
);
$dp->ingest($newProductData);
echo '' . ' mem:'.memory_get_usage() . " ... Done! <br />\n"; //memory usage check
$newProductData=null; //clear memory
unset($newProductData); //clear memory
}
unset($microline);
$dp->endImportSession(); // end import
?>
编辑:我设法让脚本工作,它的导入确定,但它不会从url导入图像
新工作守则:
<?php
$spisekKategorij = array(
'Komponente' => '738',
'Prenosniki' => '742',
'Monitorji' => '737',
);
class TestLogger
{
/**
* logging methos
*
* @param string $data
* : log content
* @param string $type
* : log type
*/
public function log($data, $type)
{
echo "$type:$data\n";
}
}
// setup include PATH's
set_include_path('magmi' . PATH_SEPARATOR . 'magmi/inc' . PATH_SEPARATOR . 'magmi/integration/inc' . PATH_SEPARATOR . 'magmi/engines');
// end include PATH's
require_once("magmi_datapump.php"); // call Datapump
$dp=Magmi_DataPumpFactory::getDataPumpInstance("productimport");
$dp->beginImportSession("123", "create"); // default- name of profile , create - we want to create and update items
$file="test.xml";
$microline = new SimpleXMLElement($file, null, true); // load XML
// $kategorija = $izdelek;
// $kategorija = (isset($spisekKategorij[$izdelek]) ? $spisekKategorij[$izdelek] : $kategorija);
foreach ($microline as $item){
$izdelek = ((string)$item->izdelekKategorija);
$kategorija = (($spisekKategorij[$izdelek]) ? $spisekKategorij[$izdelek] : $kategorija);
$newProductData = array(
"sku" => (string)$item->izdelekID .=' abbt',
"name" => (string)$item->izdelekIme,
'price' => ((real)$item->cenaBrezddv),
'description' => (string)$item->izdelekOpis . (string)$item->izdelekDodatenOpis,
'short_description' => (string)$item->izdelekDodatenOpis,
'diagonala_rshop' => (string)$item->velikost_zaslona,
'procesor_rshop' => (string)$item->procesor,
'ram_rshop' => (string)$item->ram,
'hdd_rshop' => (string)$item->disk,
'operacijski_rshop' => (string)$item->licencna_nalepka,
'locljivost_rshop' => (string)$item->locljivost,
'grafika_rshop' => (string)$item->grafika,
"attribute_set" => "test",
"store" => "rshop",
"category_ids" => $kategorija,
);
$newProductData["image"]='+'.(string)$item->slike->slika1; // + show picture, - dont show picture
$newProductData['small_image']='+'.(string)$item->slike->slika1; // small img
$newProductData['thumbnail']='+'.(string)$item->slike->slika1;
echo $izdelek;
echo $kategorija;
echo $slika;
echo '<pre>'; print_r($newProductData); echo '</pre>';
$dp->ingest($newProductData);
echo '' . ' mem:'.memory_get_usage() . " ... Done! <br />\n"; //memory usage check
$newProductData=null; //clear memory
unset($newProductData); //clear memory
}
unset($microline);
$dp->endImportSession(); // end import
?>
我的问题的解决办法是移动
进入foreach循环。我的问题的解决方案是移动
进入foreach循环。在回答关于类别的问题时,您可能不应该更新您的问题,而应该制定一个解释解决方案是什么以及为什么的答案。然后你可以问一个新问题,因为你现在的问题是不同的(你可以把新问题和前一个问题联系起来,给它一些上下文)。这对于问答网站来说很重要,因为我们为未来的访问者收集问题和答案,这样其他人就可以像我一样从你的问题和答案中受益。当你成功回答了关于该类别的问题时,也许你应该不更新你的问题,而是制定一个解释解决方案是什么以及为什么的答案。然后你可以问一个新问题,因为你现在的问题是不同的(你可以把新问题和前一个问题联系起来,给它一些上下文)。这对于问答网站来说很重要,因为我们为未来的访问者收集问题和答案,这样其他人就可以像我一样从你的问题和答案中受益。还请写下问题中前面的代码不起作用的原因,以便移动代码的理由变得清晰。这就像删除代码一样好。感谢您将评论考虑在内,不要忘了编辑问题并缩短其中的文本(编辑后的部分:由于新问题的存在,现在似乎是多余的)。还请写下问题中以前的代码不起作用的原因,以便移动代码的理据变得清晰。这就像删除代码一样好。感谢您将评论考虑在内,不要忘了编辑问题,并缩短其中的文本(编辑后的部分:由于新问题的出现,现在似乎是多余的)。
$izdelek = ((string)$item->izdelekKategorija);
$kategorija = (($spisekKategorij[$izdelek]) ? $spisekKategorij[$izdelek] : $kategorija);