Class: Item::MapSpecToTemplate
- Inherits:
-
BaseService
- Object
- BaseService
- Item::MapSpecToTemplate
- Defined in:
- app/services/item/map_spec_to_template.rb
Overview
Service object: map spec to template.
Instance Attribute Summary
Attributes inherited from BaseService
Instance Method Summary collapse
Methods inherited from BaseService
#initialize, #log_debug, #log_error, #log_info, #log_warning, #logger, #tagged_logger
Constructor Details
This class inherits a constructor from BaseService
Instance Method Details
#process ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'app/services/item/map_spec_to_template.rb', line 4 def process ProductSpecification.where.not(item_id: nil).where.not(template: true).where(template_product_specification_id: nil).find_each do |ps| # Find all specs for this item which are template res = Item::SpecificationsRetriever.new.process(ps.item, { token: ps.token, template: true }) if res.specifications.present? && (template_spec = res.specifications.first) ps.update_column(:template_product_specification_id, template_spec.id) end end end |