开发者

Adding a product using Savon to connect to Magento API

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 => “produ开发者_开发技巧ct.create”, :arguments => ["simple", 1, “testsku1”, newproductdata]} 
  end 
rescue Savon::SOAP::Fault => fault 
  puts “*****#{fault.to_s}*****” 
end

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


you are mixing array- [] and hash-syntax {}

that's why you get a SYNTAX error (there is no COMPILATION step in ruby)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜