Project

magerecord

0.01
No release in over 3 years
Low commit activity in last 3 years
A simple ActiveRecord wrapper for various Magento models
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 2.0.1

Runtime

>= 0.4.0
 Project Readme

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

  1. Fork it ( http://github.com/mystix/magerecord/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request