Class: Magento::Inventory

Inherits:
Abstract show all
Defined in:
lib/inventory.rb

Instance Attribute Summary

Attributes inherited from Abstract

#attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Abstract

commit, connect, first, #initialize, #method_missing, #object_attributes=

Constructor Details

This class inherits a constructor from Magento::Abstract

Dynamic Method Handling

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

Class Method Details

.list(*args) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/inventory.rb', line 10

def self.list(*args)
  list = []
  commit("product_stock.list", args).each do |inventory|
    list.push(new(inventory))
  end
  list
end

.update(id, *args) ⇒ Object



18
19
20
21
22
# File 'lib/inventory.rb', line 18

def self.update(id,*args)
  #commit("product_stock.update", args)
  connect
  @connection.call("product_stock.update",id,args)
end

Instance Method Details

#in_stock?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/inventory.rb', line 28

def in_stock?
  is_in_stock.to_i == 1
end

#new(attributes = {}) ⇒ Object



4
5
6
7
8
# File 'lib/inventory.rb', line 4

def new(attributes = {})
  attributes.each do |attr, val|
    instance_variable_set(:"@#{attr}",val)
  end
end

#update(*args) ⇒ Object



24
25
26
# File 'lib/inventory.rb', line 24

def update(*args)
  commit("product_stock.update", product_id, args)
end