Sha256: 8ec8854ec7fe80df45872db585195ac29a95a8d54f5e82302730a08d4e45e6b9

Contents?: true

Size: 892 Bytes

Versions: 62

Compression:

Stored size: 892 Bytes

Contents

module Workarea
  class Lint
    class InconsistentDetails < Lint
      def run
        Catalog::Product.all.each_by(100) do |product|
          all_options = product
                          .variants
                          .map { |v| v.details.keys }
                          .flatten
                          .uniq
                          .sort

          product.variants.each do |variant|
            check_details(all_options, variant)
          end
        end
      end

      def check_details(all_options, variant)
        if variant.details.blank?
          warn("#{variant.product.id},#{variant.sku},missing details")
        else
          all_options.each do |option|
            if variant.details[option].blank?
              warn("#{variant.product.id},#{variant.sku},missing detail `#{option}`")
            end
          end
        end
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.27 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.5.26 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.4.45 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.5.25 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.5.23 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.4.44 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.5.22 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.4.43 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.5.21 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.4.42 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.5.20 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.4.41 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.5.19 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.4.40 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.5.18 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.4.39 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.5.17 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.4.38 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.5.16 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.4.37 lib/workarea/lint/inconsistent_details.rb