Class: Workarea::Search::Storefront::ProductOption
- Inherits:
-
Product
- Object
- Product
- Workarea::Search::Storefront::ProductOption
- Defined in:
- app/models/workarea/search/storefront/product_option.rb
Instance Method Summary collapse
- #as_document ⇒ Object
- #category_positions ⇒ Object
- #id ⇒ Object
- #option ⇒ Object
-
#primary_image ⇒ String
URL to the primary image for display in autocomplete results.
- #skus ⇒ Object
- #value ⇒ Object
- #variants ⇒ Object
Instance Method Details
#as_document ⇒ Object
42 43 44 45 46 47 |
# File 'app/models/workarea/search/storefront/product_option.rb', line 42 def as_document result = super result[:keywords][:option] = value result[:facets][option] = [value] result end |
#category_positions ⇒ Object
21 22 23 24 25 26 |
# File 'app/models/workarea/search/storefront/product_option.rb', line 21 def category_positions Catalog::ProductPositions.find( BrowseOptionIds.for(model, value), categories: categorization.to_models ) end |
#id ⇒ Object
5 6 7 |
# File 'app/models/workarea/search/storefront/product_option.rb', line 5 def id "#{super}-#{value.optionize}" end |
#option ⇒ Object
17 18 19 |
# File 'app/models/workarea/search/storefront/product_option.rb', line 17 def option [:option] end |
#primary_image ⇒ String
URL to the primary image for display in autocomplete results.
13 14 15 |
# File 'app/models/workarea/search/storefront/product_option.rb', line 13 def primary_image ProductOptionImageUrl.new(model, option: value).url end |
#skus ⇒ Object
38 39 40 |
# File 'app/models/workarea/search/storefront/product_option.rb', line 38 def skus variants.map(&:sku) end |
#value ⇒ Object
28 29 30 |
# File 'app/models/workarea/search/storefront/product_option.rb', line 28 def value [:value].to_s end |
#variants ⇒ Object
32 33 34 35 36 |
# File 'app/models/workarea/search/storefront/product_option.rb', line 32 def variants @variants ||= model.variants.select do |variant| variant.matches_detail?(option, value) end end |