Class: Gemgento::Inventory

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ProductTouches
Defined in:
app/models/gemgento/inventory.rb

Overview

Author:

  • Gemgento LLC

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#use_config_manage_stockObject

Returns the value of attribute use_config_manage_stock.



19
20
21
# File 'app/models/gemgento/inventory.rb', line 19

def use_config_manage_stock
  @use_config_manage_stock
end

Instance Method Details

#in_stock?(quantity = 1) ⇒ Boolean

Determine if the specified quantity is in stock.

Parameters:

  • quantity (Integer) (defaults to: 1)

    the required quantity

Returns:

  • (Boolean)

    true if the required quantity is in stock



32
33
34
35
36
37
38
39
40
# File 'app/models/gemgento/inventory.rb', line 32

def in_stock?(quantity = 1)
  if !self.manage_stock?
    return true
  elsif self.is_in_stock && ((quantity.to_f <= self.quantity.to_f || quantity.to_f == 0) || self.backorders > 0)
    return true
  else
    return false
  end
end

#pushBoolean

Push the inventory data to Magento.

Returns:

  • (Boolean)

    true if the inventory data was successfully pushed to Magento



24
25
26
# File 'app/models/gemgento/inventory.rb', line 24

def push
  API::SOAP::CatalogInventory::StockItem.update(self.product);
end