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/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, 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
15
16
17
18
19
20
21
|
# File 'app/models/workarea/search/storefront.rb', line 15
def self.ensure_product_mappings
product = Workarea::Search::Storefront::Product.new(
Workarea::Catalog::Product.new(id: 'null_product')
)
product.save
Storefront.delete(product.id)
end
|
Instance Method Details
#active ⇒ Object
Whether the product is active for a given release state. Storing active per-release allows accurate previewing of products in releases on the storefront.
return [Hash]
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'app/models/workarea/search/storefront.rb', line 41
def active
model.changesets.inject(now: model.active?) do |memo, changeset|
active = if changeset.changeset['active'].respond_to?(:[])
changeset.changeset['active'][I18n.locale]
else
!!changeset.changeset['active']
end
memo[changeset.release_id.to_s] = active
memo
end
end
|
#as_document ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'app/models/workarea/search/storefront.rb', line 82
def as_document
{
id: id,
type: type,
slug: slug,
active: active,
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
|
#cache ⇒ Object
74
75
76
|
# File 'app/models/workarea/search/storefront.rb', line 74
def cache
{}
end
|
#content ⇒ Object
70
71
72
|
# File 'app/models/workarea/search/storefront.rb', line 70
def content
{}
end
|
#facets ⇒ Object
54
55
56
|
# File 'app/models/workarea/search/storefront.rb', line 54
def facets
{}
end
|
#id ⇒ Object
23
24
25
|
# File 'app/models/workarea/search/storefront.rb', line 23
def id
CGI.escape("#{type}-#{model.id}")
end
|
#keywords ⇒ Object
62
63
64
|
# File 'app/models/workarea/search/storefront.rb', line 62
def keywords
{}
end
|
#numeric ⇒ Object
58
59
60
|
# File 'app/models/workarea/search/storefront.rb', line 58
def numeric
{}
end
|
#slug ⇒ Object
31
32
33
|
# File 'app/models/workarea/search/storefront.rb', line 31
def slug
model.slug
end
|
#sorts ⇒ Object
66
67
68
|
# File 'app/models/workarea/search/storefront.rb', line 66
def sorts
{}
end
|
#suggestion_content ⇒ Object
78
79
80
|
# File 'app/models/workarea/search/storefront.rb', line 78
def suggestion_content
nil
end
|
#type ⇒ Object
27
28
29
|
# File 'app/models/workarea/search/storefront.rb', line 27
def type
model.class.name.demodulize.underscore
end
|