Magneto: connect to your magento installation
Add this line to your application's Gemfile:
gem 'magneto', github: "galorelabs/magneto"
And then execute:
$ bundle
initializer:
Magneto.configure do |config|
config.api_user = 'xxxxx'
config.api_key = 'xxxxxx'
config.wsdl_v1 = 'http://xxxxxx.com/index.php/api/soap/?wsdl'
config.wsdl_v2 = 'http://xxxxxx.com/index.php/api/v2_soap?wsdl=1'
end
use it:
Magneto.product.products_list
Magneto.product.categories
Magneto.product.product_details(9987)
Magneto.product.stock_info([9987,9884])
session = Magneto::Session.new
# If you prefer you can set config options per instance:
# options = {
# :api_user => 'xxxxx',
# :api_key => 'xxxxx',
# :wsdl_v1 => 'http://xxxxx.it/index.php/api/soap/?wsdl',
# :wsdl_v2 => 'http://xxxxx.it/index.php/api/v2_soap?wsdl=1',
# }
# session = Magneto::Session.new(options)
session.login()
session.token #return session token
session.cart #return cart object
session.cart.token #alias for session#token
session.cart.cart_id #return magento cart_id
#add products actually use product_id as hash key, as the magento 1.6 api
#works only with product_id
session.cart.add_product([{ 9987 =>1 }, { 9884 => 1} ])
#customer data
customer = {
:firstname => 'Matteo',
:lastname => 'Parmi',
:email => '[email protected]',
:company => 'Blomming',
:street => 'Via teodosio 65',
:city => 'Milano',
:region => 'MI',
:postcode => '20100',
:country_id => 'IT',
:telephone => '0123456789',
:fax => '012345678'
}
addresses = {
:shipping_address => customer,
:billing_address => customer
}
#customer only nedd :firstname, :lastname and :email
session.cart.set_customer(customer)
#set customer addresses
session.cart.set_customer_addresses(addresses)
session.cart.set_shipping_method('flatrate_flatrate')
session.cart.set_payment_method('checkmo')
session.cart.place_order
- This version is tested only Ruby MRI 1.9.3.x
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes -- and tests -- (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request