使用基于 SOAP 的 API 在 Magento 中按类别获取产品列表
我需要使用 Web 服务 API 获取属于 Magento 中特定类别的所有产品。我尝试了这个方法:
$product_filter = array(
'category_ids' => array('eq' => '41')
);
$product_templates = $magento_client -> call($magento_session, 'product.list');
但它返回一个错误。我只能假设这是因为 category_ids
是一个数组,所以它永远不会真正等于一个特定值。
我做了一些研究,发现了另一种名为 category.assignedProducts
的方法并尝试:
$product_templates =
$magento_client ->
call($magento_session, 'catalog_category.assignedProducts', array('41'));
但这返回了“访问被拒绝”错误。我查看了我的 Magneto 沙箱,发现“分配的产品”有 3 个选项:“删除”、“更新”、“分配”,并且我知道我链接到的系统的管理员已设置我的访问权限为“只读”。所以我猜我们必须在该列表中勾选“分配”,这将给我比他们想要的更多的访问权限。
我可以检索所有数据并在我这边进行过滤,但我想检查是否有人知道更好的方法。
谢谢。
I need to get all products belonging to a specific category in Magento using the web services API. I tried this method:
$product_filter = array(
'category_ids' => array('eq' => '41')
);
$product_templates = $magento_client -> call($magento_session, 'product.list');
But it returns an error. I can only assume it's because category_ids
is an array, so it won't really ever equal one specific value.
I did some research and found another method called category.assignedProducts
and tried:
$product_templates =
$magento_client ->
call($magento_session, 'catalog_category.assignedProducts', array('41'));
But this returned an 'Access Denied' error. I went and looked at my sandbox of Magneto and saw that 'Assigned Products' has 3 options: 'Remove', 'Update', 'Assign', and I know that the admin for the system I'm linking to has set my access to 'Read-Only'. So I'm guessing that we'd have to check off 'assign' in that list, which would give me more access than they want to give.
I could retrieve all of the data and do the filtering on my end, but I wanted to check if anyone knew of a better way.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
signedProducts
听起来像是您所需要的,但您不需要传递数组,而是传递整数值和商店 ID 或代码。请参阅所需的参数:http://www.magentocommerce。 com/wiki/doc/webservices-api/api/catalog_category#catalog_category.assignedproducts
assignedProducts
sounds like what you need but you shouldn't need to be passing along an array but an integer value and the store ID or code.See the arguments required: http://www.magentocommerce.com/wiki/doc/webservices-api/api/catalog_category#catalog_category.assignedproducts
我想我在 http://www.magentocommerce.com/boards/viewthread/207099 上找到了答案/ 这基本上表明它不能再从产品中完成。我们现在必须从品类的角度来看待问题。
I think I found the answer on http://www.magentocommerce.com/boards/viewthread/207099/ which basically says it can't be done from the product any more. We must now look at the problem from the category point of view.