Class: Workarea::Storefront::ContentBlocks::TaxonomyWithCategoryViewModel
- Inherits:
-
ContentBlockViewModel
- Object
- ContentBlockViewModel
- Workarea::Storefront::ContentBlocks::TaxonomyWithCategoryViewModel
- Includes:
- TaxonLookup
- Defined in:
- app/view_models/workarea/storefront/content_blocks/taxonomy_with_category_view_model.rb
Instance Method Summary collapse
Instance Method Details
#category ⇒ Object
7 8 9 10 |
# File 'app/view_models/workarea/storefront/content_blocks/taxonomy_with_category_view_model.rb', line 7 def category return @category if defined?(@category) @category = Catalog::Category.where(id: data["category"]).first end |
#product_count ⇒ Object
19 20 21 |
# File 'app/view_models/workarea/storefront/content_blocks/taxonomy_with_category_view_model.rb', line 19 def product_count Workarea.config. end |
#product_width_class ⇒ Object
23 24 25 |
# File 'app/view_models/workarea/storefront/content_blocks/taxonomy_with_category_view_model.rb', line 23 def product_width_class "grid__cell--#{100 / products.count}-at-medium" end |
#products ⇒ Object
12 13 14 15 16 17 |
# File 'app/view_models/workarea/storefront/content_blocks/taxonomy_with_category_view_model.rb', line 12 def products return [] unless category.present? @products ||= search.results.take(product_count).map do |result| ProductViewModel.wrap(result[:model]) end end |