Class: Magento::OrderItem

Inherits:
Base
  • Object
show all
Defined in:
lib/magento/order_item.rb

Instance Attribute Summary

Attributes inherited from Base

#attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base::ClassMethods

#api_path, #commit

Methods included from Base::InstanceMethods

#id=, #initialize, #method_missing, #object_attributes=

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Magento::Base::InstanceMethods

Class Method Details

.find_by_order_id_and_id(order_id, id) ⇒ Object



8
9
10
# File 'lib/magento/order_item.rb', line 8

def find_by_order_id_and_id(order_id, id)
  Magento::Order.find_by_id(order_id).order_items.select{ |i| i.id == id }.first
end

.find_by_order_number_and_id(order_number, id) ⇒ Object



4
5
6
# File 'lib/magento/order_item.rb', line 4

def find_by_order_number_and_id(order_number, id)
  Magento::Order.find_by_increment_id(order_number).order_items.select{ |i| i.id == id }.first
end

Instance Method Details

#idObject



13
14
15
# File 'lib/magento/order_item.rb', line 13

def id
  self.item_id
end

#orderObject



17
18
19
# File 'lib/magento/order_item.rb', line 17

def order
  Magento::Order.find_by_id(self.order_id)
end

#productObject



21
22
23
# File 'lib/magento/order_item.rb', line 21

def product
  Magento::Product.find_by_id_or_sku(self.product_id)
end