Class: SolidusImportProducts::UpdateProduct
- Inherits:
-
Object
- Object
- SolidusImportProducts::UpdateProduct
- Includes:
- ImportHelper
- Defined in:
- app/services/solidus_import_products/update_product.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#product ⇒ Object
Returns the value of attribute product.
-
#product_information ⇒ Object
Returns the value of attribute product_information.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
3 4 5 |
# File 'app/services/solidus_import_products/update_product.rb', line 3 def logger @logger end |
#product ⇒ Object
Returns the value of attribute product.
3 4 5 |
# File 'app/services/solidus_import_products/update_product.rb', line 3 def product @product end |
#product_information ⇒ Object
Returns the value of attribute product_information.
3 4 5 |
# File 'app/services/solidus_import_products/update_product.rb', line 3 def product_information @product_information end |
Class Method Details
.call(options = {}) ⇒ Object
7 8 9 |
# File 'app/services/solidus_import_products/update_product.rb', line 7 def self.call( = {}) new.call() end |
Instance Method Details
#call(args = { product: nil, product_information: nil }) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/services/solidus_import_products/update_product.rb', line 11 def call(args = { product: nil, product_information: nil }) self.logger = SolidusImportProducts::Logger.instance self.product_information = args[:product_information] self.product = args[:product] logger.log("UPDATE PRODUCT: #{product.inspect} #{product_information.inspect}", :debug) product.update_attribute(:deleted_at, nil) if product.deleted_at product.variants.each { |variant| variant.update_attribute(:deleted_at, nil) } properties_hash = {} product_information.each do |field, value| if field == :product_properties value.each { |prop_field, prop_value| properties_hash[prop_field] = prop_value } elsif field == :attributes value.each { |attr_field, attr_value| product.send("#{attr_field}=", attr_value) if product.respond_to?("#{attr_field}=") } end end setup_shipping_category(product) unless product.shipping_category properties_hash end |