Class: Workarea::Storefront::ContentBlocks::TaxonomyWithCategoryViewModel

Inherits:
ContentBlockViewModel
  • Object
show all
Includes:
TaxonLookup
Defined in:
app/view_models/workarea/storefront/content_blocks/taxonomy_with_category_view_model.rb

Instance Method Summary collapse

Instance Method Details

#categoryObject



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_countObject



19
20
21
# File 'app/view_models/workarea/storefront/content_blocks/taxonomy_with_category_view_model.rb', line 19

def product_count
  Workarea.config.navigation_category_summary_product_count
end

#product_width_classObject



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

#productsObject



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