Module: Workarea::Search::Storefront::Product::Text

Included in:
Workarea::Search::Storefront::Product
Defined in:
app/models/workarea/search/storefront/product/text.rb

Instance Method Summary collapse

Instance Method Details

#catalog_contentObject



6
7
8
9
10
# File 'app/models/workarea/search/storefront/product/text.rb', line 6

def catalog_content
  [model.browser_title, model.meta_description, model.description]
    .reject(&:blank?)
    .join(' ')
end

#category_namesString

A list of category names to which this product belongs, allows finding products by category names in search.

Returns:



17
18
19
# File 'app/models/workarea/search/storefront/product/text.rb', line 17

def category_names
  categorization.to_models.map(&:name).join(', ')
end

#detailsString

Text from the product’s details hash and it’s variants’ details hash. Allows finding a product by one of these values.

Returns:



44
45
46
# File 'app/models/workarea/search/storefront/product/text.rb', line 44

def details
  "#{HashText.new(model.details).text} #{variant_details_text}"
end

#details_contentString

A textual version of the product’s filters hash that will be stored and analyzed in the search index.

Returns:



35
36
37
# File 'app/models/workarea/search/storefront/product/text.rb', line 35

def details_content
  "#{HashText.new(model.details).text} #{variant_details_text}"
end

#facets_contentString

A textual version of the product’s filters hash that will be stored and analyzed in the search index.

Returns:



26
27
28
# File 'app/models/workarea/search/storefront/product/text.rb', line 26

def facets_content
  HashText.new(model.filters).text
end

#suggestion_contentString

Content to put in the index for making search query suggestions. Includes all content for the product.

Returns:



53
54
55
56
57
58
59
60
# File 'app/models/workarea/search/storefront/product/text.rb', line 53

def suggestion_content
  [
    model.name,
    category_names,
    facets_content,
    details_content
  ].join(' ')
end

#variant_details_textObject



62
63
64
65
66
# File 'app/models/workarea/search/storefront/product/text.rb', line 62

def variant_details_text
  @variant_details_text ||= model.variants.active.map do |variant|
    "#{variant.name} #{HashText.new(variant.details).text}"
  end.join(' ')
end