Magento XMLRPC API 使用 finset 运算符失败
Magento 版本 1.4.1.1
我正在尝试使用 XMLRPC API(catalog_product.list 方法调用)检索针对特定网站筛选的产品列表。服务器返回“未知错误”。我可以调用相同的方法并按状态、sku 等进行过滤。但是每当我尝试过滤可以包含多个值的字段(例如网站、类别、category_ids)时,我都会收到未知错误。
我正在使用 C# 和 Charles Cook 优秀的 xmlrpc.net 库。我已经捕获了发送到服务器的 XML,如下所示。任何人都可以深入了解为什么会发生这种情况吗?
这有效:
<?xml version="1.0"?> <methodCall> <methodName>call</methodName> <params> <param> <value> <string>81a7c4fffec8e78a6fe4b3f15f3e5cd0</string> </value> </param> <param> <value> <string>catalog_product.list</string> </value> </param> <param> <value> <array> <data> <value> <struct> <member> <name>status</name> <value> <struct> <member> <name>eq</name> <value> <string>1</string> </value> </member> </struct> </value> </member> </struct> </value> </data> </array> </value> </param> </params> </methodCall>
这不起作用:
<?xml version="1.0"?> <methodCall> <methodName>call</methodName> <params> <param> <value> <string>5d7412249845e29458b63e3b03935445</string> </value> </param> <param> <value> <string>catalog_product.list</string> </value> </param> <param> <value> <array> <data> <value> <struct> <member> <name>websites</name> <value> <struct> <member> <name>finset</name> <value> <string>1</string> </value> </member> </struct> </value> </member> </struct> </value> </data> </array> </value> </param> </params> </methodCall>
Magento version 1.4.1.1
I'm trying to retrieve a product list filtered for a specific website using the XMLRPC API (catalog_product.list method call). The server returns "unknown error". I can call this same method and filter by status, sku, etc. But anytime I try to filter on a field that can contain multiple values (e.g. websites, categories, category_ids), I get the unknown error.
I'm using C# and Charles Cook's excellent xmlrpc.net library. I've captured the XML being sent to the server as shown below. Can anyone provide any insight into why this is happening?
This works:
<?xml version="1.0"?> <methodCall> <methodName>call</methodName> <params> <param> <value> <string>81a7c4fffec8e78a6fe4b3f15f3e5cd0</string> </value> </param> <param> <value> <string>catalog_product.list</string> </value> </param> <param> <value> <array> <data> <value> <struct> <member> <name>status</name> <value> <struct> <member> <name>eq</name> <value> <string>1</string> </value> </member> </struct> </value> </member> </struct> </value> </data> </array> </value> </param> </params> </methodCall>
This doesn't:
<?xml version="1.0"?> <methodCall> <methodName>call</methodName> <params> <param> <value> <string>5d7412249845e29458b63e3b03935445</string> </value> </param> <param> <value> <string>catalog_product.list</string> </value> </param> <param> <value> <array> <data> <value> <struct> <member> <name>websites</name> <value> <struct> <member> <name>finset</name> <value> <string>1</string> </value> </member> </struct> </value> </member> </struct> </value> </data> </array> </value> </param> </params> </methodCall>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 xdebug 和 IDE 来单步执行请求并跟踪哪个类正在处理它吗?您可以阅读源代码来追踪多个条件运算符是否需要特定语法。
编辑
我记得如果只有一个节点而不是多个同级节点,XSLT 将不会创建数组。因此,如果 finset 或其他多个条件运算符需要一个数组,并且您在
下传递单个节点,则可能会作为标量接收因此函数调用失败?也许尝试发送1 2
来测试我的理论?Can you use xdebug and your IDE to step through the request and track down which class is handling it? You may be able to read the source to track down if the multiple condition operators require a particular syntax.
EDIT
I recall that XSLT will not create an array if there is a single node instead of multiple siblings. So, if
finset
or other multiple condition operators are expecting an array, and you are passing a single node under<value>
, it's possible that is being received as a scalar and hence the function call is failing? Perhaps try sending<value><string>1</string><string>2</string></value>
to test my theory?您可能想尝试一下,它可能会提供更多示例来指导您的问题:
http://code.google.com/p/csharlibformagexmlrpcapi/
You may want to give this a try, it may offer more examples as a guide to your problem:
http://code.google.com/p/csharlibformagexmlrpcapi/