Skip to content

Instantly share code, notes, and snippets.

@javiertoledo
Created March 28, 2014 11:51
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save javiertoledo/9830943 to your computer and use it in GitHub Desktop.
Save javiertoledo/9830943 to your computer and use it in GitHub Desktop.
Little snippet to get a Magento product as a Ruby Hash
# Getting a Magento product in Ruby
require 'savon'
client = Savon.client(wsdl: "http://magentohost.com/api/v2_soap?wsdl")
session_id = client.call(:login,
message: {
username: "soapusername",
api_key: "soappassword"
}).body[:login_response][:login_return]
product = client.call(:catalog_product_info,
message: {
session_id: session_id,
product: 42 #Product ID or SKU
}).body[:catalog_product_info_response][:info]
puts product # product contains a hash with the product info
@hecbuma
Copy link

hecbuma commented Apr 13, 2016

Javier, creo que la sintaxis cambio para la ultima version de savon algo asi

client = Savon.client(wsdl: "http://magentostore/api/soap/?wsdl", log_level: :info)
response = client.call(:login, message: { username: "API", apiKey: "APIKEY" })
session = response.body[:login_response][:login_return]

Oye y aprovechando, tengo unos problemas para asignar un customer a un cart, magento me dice que (1002) Can not make operation because quote is not exists no se si tu tengas conocmiento al respecto.

Gracias.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment