Sha256: 61b5f9bf40f5ecd1d2cf2d8f88a63a3e10c986ec25f000a0ca938745be4084a5

Contents?: true

Size: 859 Bytes

Versions: 3

Compression:

Stored size: 859 Bytes

Contents

module Workarea
  module Orderbot
    module Product
      class ImportParentProducts
        include Sidekiq::Worker

        def perform
          Orderbot::ProductImportData.parent_products.each do |parent_product|
            result = begin
              Orderbot::ParentProduct.new(parent_product).process

              # if a parent product has no children then import the variants
              # pricing and shipping skus
              if !parent_product.has_children
                Orderbot::ChildProduct.new(parent_product).process
              end

              true
            rescue StandardError => e
              parent_product.update_attributes!(error_message: e.message)
              false
            end

            if result
              parent_product.delete
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-orderbot-1.0.2 app/workers/workarea/orderbot/product/import_parent_products.rb
workarea-orderbot-1.0.1 app/workers/workarea/orderbot/product/import_parent_products.rb
workarea-orderbot-1.0.0 app/workers/workarea/orderbot/product/import_parent_products.rb