Sha256: ceb638cb147fd538cae7b99f8be06974148d44e27f879fe90846f350ee477942

Contents?: true

Size: 647 Bytes

Versions: 1

Compression:

Stored size: 647 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
          end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
workarea-browse_option-2.1.6 app/view_models/workarea/admin/featured_browse_option_products_view_model.rb