Sha256: 5f7c6ffe000d09518f8d4fa1736807aebce02d9e1691728988151121395e97bf
Contents?: true
Size: 1.22 KB
Versions: 62
Compression:
Stored size: 1.22 KB
Contents
module Workarea module Storefront module ContentBlocks class CategorySummaryViewModel < ContentBlockViewModel include ProductBrowsing def locals super.merge( category: category, products: products ) end def category return @category if defined?(@category) @category = Catalog::Category.where(id: data['category']).first end def products return [] unless category.present? @products ||= search.results.take(product_count).map do |result| ProductViewModel.wrap(result[:model]) end end def product_count Workarea.config.category_summary_product_count end private def search @search ||= Search::CategoryBrowse.new( category_ids: [category.id], rules: category.product_rules, page: 1, sort: sorts ) end def sorts @current_sorts ||= if category.featured_products? [:featured, category.default_sort] else [category.default_sort] end end end end end end
Version data entries
62 entries across 62 versions & 1 rubygems