Sha256: c4f360f854e73df93c916faa4cbb8df45866d1bb92af42c95ea06e0f99dde0da

Contents?: true

Size: 676 Bytes

Versions: 4

Compression:

Stored size: 676 Bytes

Contents

module Workarea
  module Admin
    module FeaturedBrowseOptionProductsViewModel
      def featured_products
        @featured_products ||=
          begin
            models = Catalog::Product.any_in(id: model.unique_product_ids).to_a

            results = model.product_ids.map do |id|
              id, option = BrowseOptionIds.split(id)
              tmp = models.detect { |m| m.id == id }
              next unless tmp.present?

              Admin::FeaturedBrowseOptionProductViewModel.new(
                tmp,
                tmp.browse_option => option&.optionize
              )
            end

            results.compact
          end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
workarea-browse_option-2.2.0 app/view_models/workarea/admin/featured_browse_option_products_view_model.rb
workarea-browse_option-2.1.9 app/view_models/workarea/admin/featured_browse_option_products_view_model.rb
workarea-browse_option-2.1.8 app/view_models/workarea/admin/featured_browse_option_products_view_model.rb
workarea-browse_option-2.1.7 app/view_models/workarea/admin/featured_browse_option_products_view_model.rb