Adding a product using Savon to connect to Magento API

空扰寡人 提交于 2019-12-03 00:10:59

问题


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

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

回答1:


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

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



来源:https://stackoverflow.com/questions/7634928/adding-a-product-using-savon-to-connect-to-magento-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!