Class: SolidusImportProducts::SaveProperties
- Inherits:
-
Object
- Object
- SolidusImportProducts::SaveProperties
- Defined in:
- app/services/solidus_import_products/save_properties.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#product ⇒ Object
Returns the value of attribute product.
-
#properties_hash ⇒ Object
Returns the value of attribute properties_hash.
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/save_properties.rb', line 3 def logger @logger end |
#product ⇒ Object
Returns the value of attribute product.
3 4 5 |
# File 'app/services/solidus_import_products/save_properties.rb', line 3 def product @product end |
#properties_hash ⇒ Object
Returns the value of attribute properties_hash.
3 4 5 |
# File 'app/services/solidus_import_products/save_properties.rb', line 3 def properties_hash @properties_hash end |
Class Method Details
.call(options = {}) ⇒ Object
5 6 7 |
# File 'app/services/solidus_import_products/save_properties.rb', line 5 def self.call( = {}) new.call() end |
Instance Method Details
#call(args = { product: nil, properties_hash: nil }) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/services/solidus_import_products/save_properties.rb', line 9 def call(args = { product: nil, properties_hash: nil }) self.logger = SolidusImportProducts::Logger.instance self.properties_hash = args[:properties_hash] self.product = args[:product] properties_hash.each do |field, value| property = Spree::Property.where('lower(name) = ?', field).first next unless property product_property = Spree::ProductProperty.where(product_id: product.id, property_id: property.id).first_or_initialize product_property.value = value product_property.save! end end |