Magento API - 几种方法不起作用
我有以下问题。我构建了一个 PHP 文件,它从文件中读取类别,并将它们导入到 Magento 中。我能够读取该文件,没问题。通过 NuSOAP 与 Magento API 的连接也可以正常工作。我可以获得 SessionID,并且能够获取数据,例如类别的信息,也可以删除类别。
但是,每当我尝试创建或更新任何内容时,它都会引发错误。用户的权利也没有问题。例如,当我创建一个类别时,我将常用数据添加到调用中:
$proxy->call(
$sessionId,
'category.create',
$rootCategory, array(
'name' => "TEST",
'is_active' => '1',
'page_layout' => 'two_columns_right',
'description' => "TEST",
'meta_title' => "TEST",
'meta_description' => '',
'meta_keywords' => "TEST",
'include_in_menu' => '0',
'display_mode' => 'PRODUCTS',
'available_sort_by' => 'price',
'default_sort_by' => 'price',
'is_anchor' => '0'
)
);
始终,它显示:
( [故障代码] => 102 [故障字符串] =>类别不存在。 )
这不是真的。 $rootCategory 绝对是一个现有的类别。我尝试了所有其他类别,我尝试向信息添加“路径”,我尝试使用更少的信息(仅必要的内容),我尝试读取现有类别以获取它们的 ID,但没有任何效果。它总是抛出此故障代码。 当我尝试更新类别或创建/更新产品时,也会发生同样的情况。删除完全没有问题。 你看到问题了吗?
I've got the following problem. I built a PHP file, which reads categories from a file, to impor tthem into Magento. I am able to read the file, no problem. The connection via NuSOAP to the Magento API works aswell. I can get the SessionID and I am able to get data, like Information for a category, also its possible to delete categories.
But, whenever I try to create or update anything, it throws an error. The rights for the user are ok aswell. For example, when I create a category, I add the usual data to the call:
$proxy->call(
$sessionId,
'category.create',
$rootCategory, array(
'name' => "TEST",
'is_active' => '1',
'page_layout' => 'two_columns_right',
'description' => "TEST",
'meta_title' => "TEST",
'meta_description' => '',
'meta_keywords' => "TEST",
'include_in_menu' => '0',
'display_mode' => 'PRODUCTS',
'available_sort_by' => 'price',
'default_sort_by' => 'price',
'is_anchor' => '0'
)
);
All the time, it says:
(
[faultcode] => 102
[faultstring] => Category not exists. )
Which is not true. The $rootCategory is definatly a category, which is existing. I tried all other categories, I tried to add a 'path' to the info, I tried to use less information (only the neccesary stuff), I tried to read existing categories to get their IDs, NOTHING works. It always throws this faultcode.
Same happens, when I try to update a category, or create /update a product. Deleting is no problem at all.
Do you see the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我刚刚比较了你的非工作示例,在与我拥有的另一个示例进行比较时发现了这一点(我并不假装是专家)..
但看起来像你的 $new_category, array(blahblha) ...
根据我已经拥有的示例,应该在一个数组内部
($new_category,array(blahblah)...
这是我刚刚看到的主要区别..
这是我刚刚从网络中取出的示例...适应您的需求..
i just compared your NON working exemple and i found this while comparing it with another exemple i has ( i do not pretent to be expert ) ..
but seems like your $new_category, array(blahblha) ...
should be INSIDE an array according to the exemple i already have
like this array($new_category,array(blahblah) ...
this is the mains difference i just saw ..
here is the EXEMPLE i just pulled out of the web ... Adapt to your needs..
您是否尝试在调用中指定 $rootCategory 中的category_id 键:
$selectedCategory['category_id'],
array('name'=>'通过 Soap 新建类别')
)
参考:http://www.magentocommerce.com/ wiki/doc/webservices-api/api/catalog_category
Have you tried specifying the category_id key in your $rootCategory within the call:
$selectedCategory['category_id'],
array('name'=>'New Category Through Soap')
)
Reference: http://www.magentocommerce.com/wiki/doc/webservices-api/api/catalog_category