我已经打了好几个电话,但对于我的生活,我无法弄清楚如何让product_attribute.create
工作。我总是得到102 Invalid request parameters
或623 Wrong Method Signature
。
像这样my $res = $self->_useragent->call( call => $self->_session, @{$payload} );
进行调用(注意:useragent是一个XML::RPC对象。
这Dumper $payload
;
$VAR1 = [
'product_attribute.create',
[
'test',
{
'frontend_label' => [
{
'label' => 'Test ME',
'store_id' => 0
}
],
'scope' => 'store',
'frontend_input' => 'text'
}
]
];
我已经阅读了API Documentation,但是弄清楚Perl中的调用应该是什么样的。
答案 0 :(得分:1)
我不熟悉您在perl中使用的XML-RPC库,但是您看到的错误是Magento API异常,在
中配置<!--File: app/code/core/Mage/Catalog/etc/api.xml -->
<!-- ... -->
<invalid_parameters>
<code>102</code>
<message>Invalid request parameters.</message>
</invalid_parameters>
<!-- ... -->
使用例外的名称,你可以找到Magento扔它的地方
#File: app/code/core/Mage/Catalog/Model/Product/Attribute/Api.php
//...
if (empty($data['attribute_code']) || !is_array($data['frontend_label'])) {
$this->_fault('invalid_parameters');
}
//...
所以,我的猜测是你的电话是正确的,你只是错过了attribute_code
。
答案 1 :(得分:0)
在通过Magento的代码进行一些挖掘之后,我将其从测试套件中复制并转换为perl,它似乎可行。也许所有属性都是必需的。
$VAR1 = [
'product_attribute.create',
[
{
'default_value' => '1',
'is_configurable' => 0,
'used_in_product_listing' => 0,
'is_visible_on_front' => 0,
'apply_to' => [
'simple'
],
'is_comparable' => 0,
'is_used_for_promo_rules' => 0,
'is_required' => 0,
'scope' => 'store',
'is_unique' => 0,
'frontend_input' => 'text',
'is_searchable' => 0,
'attribute_code' => 'unique_code',
'is_visible_in_advanced_search' => 0,
'frontend_label' => [
{
'label' => 'some label',
'store_id' => '0'
}
]
}
]
];
有些基于Alan Storm's Answer的进一步实验表明需要以下字段,因为我无法在没有定义所有这些字段的情况下成功创建请求。
$VAR1 = [
'product_attribute.create',
[
{
'frontend_input' => 'text',
'attribute_code' => 'test1374438470',
'frontend_label' => [
{
'store_id' => 0,
'label' => 'Test ME'
}
]
}
]
];