すでにいくつかの電話がかかってきましたが、私の人生では、どのように電話をかけるかがわかりません。 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ドキュメント しかし、Perlでの呼び出しがどのように見えるかを理解するのは難しいです。
回答:
回答№1は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
.
回答№2の場合は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"
}
]
}
]
];
やや基づいたさらなる実験 アランストームの答え、少なくともこれらのフィールドをすべて定義しないとリクエストを正常に作成できなかったため、次のフィールドが必須であることをお勧めします。
$VAR1 = [
"product_attribute.create",
[
{
"frontend_input" => "text",
"attribute_code" => "test1374438470",
"frontend_label" => [
{
"store_id" => 0,
"label" => "Test ME"
}
]
}
]
];