使用基于 SOAP 的 API 在 Magento 中按类别获取产品列表

发布于 2024-10-31 15:13:48 字数 749 浏览 1 评论 0原文

我需要使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

圈圈圆圆圈圈 2024-11-07 15:13:49

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

紫竹語嫣☆ 2024-11-07 15:13:49

我想我在 http://www.magentocommerce.com/boards/viewthread/207099 上找到了答案/ 这基本上表明它不能再从产品中完成。我们现在必须从品类的角度来看待问题。

category_ids 在 1.4 中不再起作用,他们更改了表
周围的结构,以便类别在
产品。使用下面的代码从类别中获取产品并
然后进行catalog_product.list 调用。为了使其更快,您还可以
创建一个自定义 api 解决方案以在 Magento 中组合这些并执行
只需一次调用,而不是两次。

$proxy = new SoapClient($soapUrl.'api/soap/?wsdl'); $会话ID =
$proxy->login($apiUser, $apiPass);

$productList = $proxy->call($sessionId,
'catalog_category.assignedProducts', array('4'));
$proxy->endSession($sessionId); print_r($productList);

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.

category_ids no longer works in 1.4, they changed the table
structures around so that the categories are not available on the
product. Use the code below to get the products from the category and
then do a catalog_product.list call. To make it faster you can also
create a custom api solution to combine these in Magento and perform
just one call instead of two.

$proxy = new SoapClient($soapUrl.’api/soap/?wsdl’); $sessionId =
$proxy->login($apiUser, $apiPass);

$productList = $proxy->call($sessionId,
‘catalog_category.assignedProducts’, array(’4’));
$proxy->endSession($sessionId); print_r($productList);

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文