Class: Workarea::Storefront::ContentBlocks::CategorySummaryViewModel
Instance Method Summary
collapse
#facets, #filters, #has_filters?, #product_browse_cache_key
Methods included from Pagination
#first_page?, #last_page?, #next_page, #prev_page, #search_query, #second_page?, #total_pages
#asset_alt_text, #assets, #find_asset, #partial, #series, wrap
Instance Method Details
#category ⇒ Object
14
15
16
17
|
# File 'app/view_models/workarea/storefront/content_blocks/category_summary_view_model.rb', line 14
def category
return @category if defined?(@category)
@category = Catalog::Category.where(id: data['category']).first
end
|
#locals ⇒ Object
7
8
9
10
11
12
|
# File 'app/view_models/workarea/storefront/content_blocks/category_summary_view_model.rb', line 7
def locals
super.merge(
category: category,
products: products
)
end
|
#product_count ⇒ Object
26
27
28
|
# File 'app/view_models/workarea/storefront/content_blocks/category_summary_view_model.rb', line 26
def product_count
Workarea.config.category_summary_product_count
end
|
#products ⇒ Object
19
20
21
22
23
24
|
# File 'app/view_models/workarea/storefront/content_blocks/category_summary_view_model.rb', line 19
def products
return [] unless category.present?
@products ||= search.results.take(product_count).map do |result|
ProductViewModel.wrap(result[:model])
end
end
|