当前位置 : 主页 > 编程语言 > ruby >

ruby-on-rails-3 – 使用Savon gem(SOAP)在Ruby on Rails中使用API​​ Magento过滤产品

来源:互联网 收集:自由互联 发布时间:2021-06-23
我正在使用 this code作为我的rails应用程序与Magento的API.一切都很好,除了一件事,我需要通过Magento API的参数过滤产品,但我不知道如何:( 显然我已经测试了更多的解决方案(数组,哈希等),但
我正在使用 this code作为我的rails应用程序与Magento的API.一切都很好,除了一件事,我需要通过Magento API的参数过滤产品,但我不知道如何:(

显然我已经测试了更多的解决方案(数组,哈希等),但是
不成功.

钯:对不起,我的英语非常有限

链接

>相关案例(失败):Adding a product using Savon to connect to Magento API
>示例:http://www.polyvision.org/2011/10/02/using-magento-soap-api-with-ruby-and-savon.html

我知道这已经很晚了,但如果有其他人找到这个帖子,我已经创建了一个magento_api_wrapper gem,它实现了Magento SOAP API v2的过滤器.你可以在这里找到代码: https://github.com/harrisjb/magento_api_wrapper

总而言之,如果要使用其中一个Magento SOAP API简单过滤器,则可以传递带有键和值的哈希:

api = MagentoApiWrapper::Catalog.new(magento_url: "yourmagentostore.com/index.php", magento_username: "soap_api_username", magento_api_key: "userkey123")

api.product_list(simple_filters: [{key: "status", value: "processing"}, {key: created_at, value: "12/10/2013 12:00" }])

要使用复杂的过滤器,请使用键,运算符和值传递散列:

api.product_list(complex_filters: [{key: "status", operator: "eq", value: ["processing", "completed"]}, {key: created_at, operator: "from", value: "12/10/2013" }])
网友评论