我在使用magmi数据泵api导入自定义选项时遇到一些问题。我可以通过在magmi的例子中给出的数组中传递数据来轻松上传产品。
但是,当我安装自定义选项模块并启用它时,我会收到以下错误。
...
$dp->beginImportSession("default","create");
// Here we define a single "simple" item, with name, sku,price,attribute_set,store,description
$item = array(
'name' => 'test a',
'sku' => 'testsku3',
'price' => '110.00',
'attribute_set' => 'Default',
'store' => 'admin',
'description' => 'ingested with Datapump API',
'meta_title' => 'test meta',
'qty' => '1',
'categories' => '2',
'weight' => '1',
'tax_class_id' => '4',
'Please enter your text:field:1:3' => ':fixed:0.5:Ref Text:35'
);
...
返回错误:
Notice: Undefined index: xxx:field:1 in /var/www/vhosts/websitename.co.uk/magmi/plugins/extra/itemprocessors/customoptions/pablo_customoptions.php on line 33
现在这个错误代码解析为…
...
public function getOptId($field)
{
return $this->_optids[$field];
}
...
有人知道如何解决这个问题吗?
谢谢!:)
行
'请输入您的文本:字段:1:3'=>':固定:0.5:参考文本:35'
将创建此错误。
通过编辑php文件修复它
...
public function getOptId($field)
{
if isset($this->_optids[$field]) return $this->_optids[$field];
return '';
}
...
或者更好的"请输入您的文本",如脚本中所说;)用您的自定义属性替换此行
'Please enter your text:field:1:3' => ':fixed:0.5:Ref Text:35'
EDIT TO:
'custom_attribute' => 'value',
Simon
所以我也遇到了同样的问题,非常头疼。上面的解决方案有点奏效,因为创建的产品没有错误,但没有添加自定义选项。
然而,我设法创建了一个解决方案!
我试图使用以下标签为我的产品添加一个自定义选项:
date_time:field:1:1
这引发了与你完全相同的错误。然而,它的格式是应该的。
为了解决这个问题,我不得不编辑文件:/magmi/plugins/extra/itemprocessors/customoptions/pablo_customotions.php
我将getOptId()函数(第30行)更改为:
public function getOptId($field)
{
if(isset($this->_optids[$field])){
return $this->_optids[$field];
} else {
return false;
}
}
并对createOption()函数进行了更改(现在位于第74行)。我将if(!isset($optionId))
更改为if(!$optionId)
宾果,它现在应该如预期的那样工作了!