Class: Workarea::Search::Storefront
- Inherits:
-
Object
- Object
- Workarea::Search::Storefront
show all
- Includes:
- Elasticsearch::Document
- Defined in:
- app/models/workarea/search/storefront.rb,
app/models/workarea/search/storefront/page.rb,
app/models/workarea/search/storefront/search.rb,
app/models/workarea/search/storefront/product.rb,
app/models/workarea/search/storefront/category.rb,
app/models/workarea/search/storefront/product/text.rb,
app/models/workarea/search/storefront/category_query.rb,
app/models/workarea/search/storefront/product/facets.rb,
app/models/workarea/search/storefront/product/pricing.rb,
app/models/workarea/search/storefront/product/sorting.rb,
app/models/workarea/search/storefront/product/analytics.rb,
app/models/workarea/search/storefront/product/inventory.rb,
app/models/workarea/search/storefront/product/categories.rb
Defined Under Namespace
Classes: Category, CategoryQuery, Page, Product, Search
Class Method Summary
collapse
Instance Method Summary
collapse
all, #as_bulk_document, current_index_prefix, #destroy, #initialize, #save
Class Method Details
.ensure_dynamic_mappings ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'app/models/workarea/search/storefront.rb', line 6
def self.ensure_dynamic_mappings
ensure_product_mappings
end
|
.ensure_product_mappings ⇒ Object
Instance Method Details
#active ⇒ Object
Whether the product is active. Stored as ‘:now` way for upgrade support to v3.5 without requiring reindexing.
return [Hash]
45
46
47
|
# File 'app/models/workarea/search/storefront.rb', line 45
def active
{ now: model.active? }
end
|
#active_segment_ids ⇒ Object
49
50
51
|
# File 'app/models/workarea/search/storefront.rb', line 49
def active_segment_ids
model.try(:active_segment_ids)
end
|
#as_document ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'app/models/workarea/search/storefront.rb', line 81
def as_document
Release.with_current(release_id) do
{
id: id,
type: type,
slug: slug,
active: active,
active_segment_ids: active_segment_ids,
release_id: release_id,
changeset_release_ids: Array.wrap(model.try(:changesets)).map(&:release_id),
suggestion_content: suggestion_content,
created_at: model.created_at,
updated_at: model.updated_at,
facets: facets,
numeric: numeric,
keywords: keywords,
sorts: sorts,
content: content,
cache: cache
}
end
end
|
#cache ⇒ Object
73
74
75
|
# File 'app/models/workarea/search/storefront.rb', line 73
def cache
{}
end
|
#content ⇒ Object
69
70
71
|
# File 'app/models/workarea/search/storefront.rb', line 69
def content
{}
end
|
#facets ⇒ Object
53
54
55
|
# File 'app/models/workarea/search/storefront.rb', line 53
def facets
{}
end
|
#id ⇒ Object
23
24
25
26
|
# File 'app/models/workarea/search/storefront.rb', line 23
def id
pieces = [type, model.id, model.try(:release_id)].reject(&:blank?)
CGI.escape(pieces.join('-'))
end
|
#keywords ⇒ Object
61
62
63
|
# File 'app/models/workarea/search/storefront.rb', line 61
def keywords
{}
end
|
#numeric ⇒ Object
57
58
59
|
# File 'app/models/workarea/search/storefront.rb', line 57
def numeric
{}
end
|
#release_id ⇒ Object
36
37
38
|
# File 'app/models/workarea/search/storefront.rb', line 36
def release_id
model.try(:release_id).presence || 'live'
end
|
#slug ⇒ Object
32
33
34
|
# File 'app/models/workarea/search/storefront.rb', line 32
def slug
model.slug
end
|
#sorts ⇒ Object
65
66
67
|
# File 'app/models/workarea/search/storefront.rb', line 65
def sorts
{}
end
|
#suggestion_content ⇒ Object
77
78
79
|
# File 'app/models/workarea/search/storefront.rb', line 77
def suggestion_content
nil
end
|
#type ⇒ Object
28
29
30
|
# File 'app/models/workarea/search/storefront.rb', line 28
def type
model.class.name.demodulize.underscore
end
|