Class: Prestashop::Mapper::Combination
- Defined in:
- lib/prestashop/mapper/models/combination.rb
Instance Attribute Summary collapse
-
#available_date ⇒ Object
Returns the value of attribute available_date.
-
#default_on ⇒ Object
Returns the value of attribute default_on.
-
#ean13 ⇒ Object
Returns the value of attribute ean13.
-
#ecotax ⇒ Object
Returns the value of attribute ecotax.
-
#id ⇒ Object
(also: #find?)
ID of combination, or find ID by
reference
andid_product
. -
#id_images ⇒ Object
Returns the value of attribute id_images.
-
#id_lang ⇒ Object
Returns the value of attribute id_lang.
-
#id_product ⇒ Object
Returns the value of attribute id_product.
-
#id_product_options ⇒ Object
Returns the value of attribute id_product_options.
-
#location ⇒ Object
Returns the value of attribute location.
-
#minimal_quantity ⇒ Object
Returns the value of attribute minimal_quantity.
-
#price ⇒ Object
Returns the value of attribute price.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
-
#reference ⇒ Object
Returns the value of attribute reference.
-
#supplier_reference ⇒ Object
Returns the value of attribute supplier_reference.
-
#unit_price_impact ⇒ Object
Returns the value of attribute unit_price_impact.
-
#upc ⇒ Object
Returns the value of attribute upc.
-
#weight ⇒ Object
Returns the value of attribute weight.
-
#wholesale_price ⇒ Object
Returns the value of attribute wholesale_price.
Class Method Summary collapse
Instance Method Summary collapse
- #hash ⇒ Object
-
#initialize(args = {}) ⇒ Combination
constructor
A new instance of Combination.
- #update(options = {}) ⇒ Object
Methods inherited from Model
#hash_lang, #meta_description, #meta_keywords, #meta_title, model, resource
Methods included from Extension
Constructor Details
#initialize(args = {}) ⇒ Combination
Returns a new instance of Combination.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/prestashop/mapper/models/combination.rb', line 12 def initialize args = {} @id = args[:id] @id_product = args.fetch(:id_product) @location = args[:location] @ean13 = args[:ean] @upc = args[:upc] @quantity = args.fetch(:quantity, 0) @reference = args.fetch(:reference) @supplier_reference = args[:supplier_reference] @wholesale_price = args[:wholesale_price] @price = args[:price] @ecotax = args[:ecotax] @weight = args[:weight] @unit_price_impact = args[:unit_price_impact] @minimal_quantity = args.fetch(:minimal_quantity, 1) @default_on = args.fetch(:default_on, 0) @available_date = Date.today.strftime("%F") @id_product_options = args[:id_product_options] @id_images = args[:id_images] @id_lang = args.fetch(:id_lang) end |
Instance Attribute Details
#available_date ⇒ Object
Returns the value of attribute available_date.
9 10 11 |
# File 'lib/prestashop/mapper/models/combination.rb', line 9 def available_date @available_date end |
#default_on ⇒ Object
Returns the value of attribute default_on.
9 10 11 |
# File 'lib/prestashop/mapper/models/combination.rb', line 9 def default_on @default_on end |
#ean13 ⇒ Object
Returns the value of attribute ean13.
9 10 11 |
# File 'lib/prestashop/mapper/models/combination.rb', line 9 def ean13 @ean13 end |
#ecotax ⇒ Object
Returns the value of attribute ecotax.
9 10 11 |
# File 'lib/prestashop/mapper/models/combination.rb', line 9 def ecotax @ecotax end |
#id ⇒ Object Also known as: find?
ID of combination, or find ID by reference
and id_product
37 38 39 |
# File 'lib/prestashop/mapper/models/combination.rb', line 37 def id @id end |
#id_images ⇒ Object
Returns the value of attribute id_images.
8 9 10 |
# File 'lib/prestashop/mapper/models/combination.rb', line 8 def id_images @id_images end |
#id_lang ⇒ Object
Returns the value of attribute id_lang.
8 9 10 |
# File 'lib/prestashop/mapper/models/combination.rb', line 8 def id_lang @id_lang end |
#id_product ⇒ Object
Returns the value of attribute id_product.
9 10 11 |
# File 'lib/prestashop/mapper/models/combination.rb', line 9 def id_product @id_product end |
#id_product_options ⇒ Object
Returns the value of attribute id_product_options.
8 9 10 |
# File 'lib/prestashop/mapper/models/combination.rb', line 8 def @id_product_options end |
#location ⇒ Object
Returns the value of attribute location.
9 10 11 |
# File 'lib/prestashop/mapper/models/combination.rb', line 9 def location @location end |
#minimal_quantity ⇒ Object
Returns the value of attribute minimal_quantity.
9 10 11 |
# File 'lib/prestashop/mapper/models/combination.rb', line 9 def minimal_quantity @minimal_quantity end |
#price ⇒ Object
Returns the value of attribute price.
9 10 11 |
# File 'lib/prestashop/mapper/models/combination.rb', line 9 def price @price end |
#quantity ⇒ Object
Returns the value of attribute quantity.
9 10 11 |
# File 'lib/prestashop/mapper/models/combination.rb', line 9 def quantity @quantity end |
#reference ⇒ Object
Returns the value of attribute reference.
9 10 11 |
# File 'lib/prestashop/mapper/models/combination.rb', line 9 def reference @reference end |
#supplier_reference ⇒ Object
Returns the value of attribute supplier_reference.
9 10 11 |
# File 'lib/prestashop/mapper/models/combination.rb', line 9 def supplier_reference @supplier_reference end |
#unit_price_impact ⇒ Object
Returns the value of attribute unit_price_impact.
9 10 11 |
# File 'lib/prestashop/mapper/models/combination.rb', line 9 def unit_price_impact @unit_price_impact end |
#upc ⇒ Object
Returns the value of attribute upc.
9 10 11 |
# File 'lib/prestashop/mapper/models/combination.rb', line 9 def upc @upc end |
#weight ⇒ Object
Returns the value of attribute weight.
9 10 11 |
# File 'lib/prestashop/mapper/models/combination.rb', line 9 def weight @weight end |
#wholesale_price ⇒ Object
Returns the value of attribute wholesale_price.
9 10 11 |
# File 'lib/prestashop/mapper/models/combination.rb', line 9 def wholesale_price @wholesale_price end |
Class Method Details
.deactivate(supplier) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/prestashop/mapper/models/combination.rb', line 70 def deactivate supplier first = (Date.today-365).strftime("%F") last = (Date.today-1).strftime("%F") combinations = where 'filter[date_upd]' => "[#{first},#{last}]", date: 1, 'filter[supplier_reference]' => supplier, limit: 1000 if combinations and !combinations.empty? combinations.map{|c| delete(c)} end end |
Instance Method Details
#hash ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/prestashop/mapper/models/combination.rb', line 42 def hash combination = { id_product: id_product, reference: reference, supplier_reference: supplier_reference, minimal_quantity: minimal_quantity, default_on: default_on, available_date: available_date, price: price, quantity: quantity, associations: {} } if combination[:associations][:product_option_values] = {} combination[:associations][:product_option_values][:product_option_value] = hash_ids() end if id_images combination[:associations][:images] = {} combination[:associations][:images][:image] = hash_ids(id_images) end combination end |
#update(options = {}) ⇒ Object
65 66 67 |
# File 'lib/prestashop/mapper/models/combination.rb', line 65 def update = {} self.class.update(id, ) end |