MageRecord
RubyGem¶ ↑
Introduction¶ ↑
Simple ActiveRecord wrapper for various Magento models.
Installation¶ ↑
Add this line to your application’s Gemfile:
gem 'magerecord'
And then execute:
$ bundle
Or install it yourself as:
$ gem install magerecord
Basic Usage:¶ ↑
# require 'activerecord-jdbc-adapter' # if running jruby # IMPORTANT: initialise magento mysql database connection MageRecord::Connection.new 'localhost', 'db_name', 'username', 'password' # get total number of orders MageRecord::Order.count # get latest order order = MageRecord::Order.last # get order items order.items # get associated products order.products # get customer's full name order.customer.firstname + ' ' + order.customer.lastname # get billing address order.billing_address # get shipping address order.shipping_address # get EAV attributes for the following Magento models: # - MageRecord::Address # - MageRecord::Customer # - MageRecord::Product MageRecord::Address.eav_attributes MageRecord::Customer.eav_attributes MageRecord::Product.eav_attributes # get a product product = MageRecord::Product.last # get product name product.name # get custom product EAV attribute # (note: these should first be defined in Magento) product.flavor product.size product.color # get product stock level product.qty
Contributing¶ ↑
-
Fork it ( github.com/mystix/magerecord/fork )
-
Create your feature branch (
git checkout -b my-new-feature
) -
Commit your changes (
git commit -am 'Add some feature'
) -
Push to the branch (
git push origin my-new-feature
) -
Create new Pull Request