Class: Workarea::Listrak::ProductExporter
- Inherits:
-
Object
- Object
- Workarea::Listrak::ProductExporter
- Includes:
- Sidekiq::CallbacksWorker, Sidekiq::Worker
- Defined in:
- app/workers/workarea/listrak/product_exporter.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.perform_with(model) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'app/workers/workarea/listrak/product_exporter.rb', line 17 def self.perform_with(model) case model.class.name when "Workarea::Pricing::Price" [model.sku.class.name, model.sku.id] else [model.class.name, model.id] end end |
Instance Method Details
#perform(class_name, id) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/workers/workarea/listrak/product_exporter.rb', line 26 def perform(class_name, id) product, skus = if class_name == "Workarea::Catalog::Product" prod = Catalog::Product.find(id) [prod, prod.skus] else [Catalog::Product.find_by_sku(id), [id]] end return unless product.present? inventory = Inventory::Collection.new product.skus pricing = Inventory::Collection.new product.skus listrak_products = skus.map do |sku| Listrak::Models::ProductForm.new product, pricing_sku: pricing.for_sku(sku), inventory_sku: inventory.for_sku(sku) end Workarea::Listrak.data.products.import(listrak_products) end |