Sha256: fc5798863651eb78d18229b0a1c50c70d59945825c4adb4924703489f19764b1

Contents?: true

Size: 677 Bytes

Versions: 2

Compression:

Stored size: 677 Bytes

Contents

module Magento
  class OrderItem < Base
    class << self      
      def find_by_id(id)
        Magento::Order.list.each do |order|
          item = Order.find_by_increment_id(order.increment_id).order_items.select{ |i| i.id == id }
          return item.first if item and item.first
        end
      end
      
      def find_by_order_and_id(order_id, id)
        Magento::Order.find_by_id(order_id).order_items.select{ |i| i.id == id }.first
      end
    end
    
    def id
      self.item_id
    end
    
    def order
      Magento::Order.find_by_id(self.order_id)
    end
    
    def product
      Magento::Product.find_by_id_or_sku(self.product_id)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
magentor-0.2.10 lib/magento/order_item.rb
magentor-0.2.9 lib/magento/order_item.rb