Sha256: d18bddd5a1fad7e8c222e831119845fbfec3f9b8264e9f6993f28e827c479dc7

Contents?: true

Size: 561 Bytes

Versions: 2

Compression:

Stored size: 561 Bytes

Contents

module Workarea
  module Storefront
    module ContentBlocks
      class TaxonomyWithProductsViewModel < ContentBlockViewModel
        include TaxonLookup

        def products
          return [] unless data["products"].present?

          @products ||= Catalog::Product
                          .find_ordered_for_display(data["products"])
                          .map { |product| ProductViewModel.wrap(product) }
        end

        def product_width_class
          "grid__cell--#{100 / products.count}-at-medium"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workarea-one_theme-1.3.1 app/view_models/workarea/storefront/content_blocks/taxonomy_with_products_view_model.rb
workarea-one_theme-1.3.0 app/view_models/workarea/storefront/content_blocks/taxonomy_with_products_view_model.rb