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.4.27 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.5.4 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.4.26 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.5.3 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.4.25 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.5.2 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.4.24 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.5.1 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.4.23 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.4.22 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.5.0 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.4.21 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.5.0.beta.1 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.4.20 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.4.19 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.4.18 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.4.17 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.4.16 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.4.15 lib/workarea/lint/inconsistent_details.rb
workarea-core-3.4.14 lib/workarea/lint/inconsistent_details.rb