问题描述
我有用于在Ruby中列出产品的代码,但正在努力添加产品,这是我的代码,我将savon gem用于HTTP/SOAP请求,基于此处的代码 http://www.polyvision.org/2011 /10/02/使用magento-soap-api-with-ruby-and-savon/
I have got the code working for listing products in Ruby but am struggling to add a product, here is my code, I’m using the savon gem for HTTP/SOAP requests, based on the code here http://www.polyvision.org/2011/10/02/using-magento-soap-api-with-ruby-and-savon/
# Insert some products ...
newproductdata = [
["name" , "test product"],
["websites" , [1]],
["short_description" , ‘short description’],
["description" , ‘description’],
["status" , 1],
["weight" , 0],
["tax_class_id" , 1],
["categories" , [3]],
["price" , 12.05]
]
begin
response = client.request :call do
soap.body = {:session => session, :method => "product.create", :arguments => ["simple", 1, "testsku1", newproductdata]}
end
rescue Savon::SOAP::Fault => fault
puts "*****#{fault.to_s}*****"
end
我认为问题在于:arguments的传入,也许需要正确命名,此代码会产生错误,
I think the issue is the passing in of :arguments which perhaps needs to be named correctly, this code generates the error,
(SOAP-ENV:Client) Error cannot find parameter
推荐答案
您正在混合使用array- []和哈希语法{}
you are mixing array- [] and hash-syntax {}
这就是为什么出现SYNTAX错误的原因(ruby中没有COMPILATION步骤)
that's why you get a SYNTAX error (there is no COMPILATION step in ruby)
这篇关于使用Savon添加产品以连接到Magento API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!