Class: Workarea::Search::Admin::CatalogProduct
Instance Method Summary
collapse
#as_document, #created_at, for, #id, jump_to, #jump_to_param, #jump_to_route_helper, #name, #releasable?, #sanitized_keywords, #should_be_indexed?, #type, #updated_at
all, #as_bulk_document, #as_document, current_index_prefix, #destroy, #initialize, #save
Instance Method Details
#category_ids ⇒ Object
54
55
56
|
# File 'app/models/workarea/search/admin/catalog_product.rb', line 54
def category_ids
@category_ids ||= model.category_ids
end
|
#facets ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'app/models/workarea/search/admin/catalog_product.rb', line 45
def facets
super
.merge(Search::Storefront::Product.new(model).facets)
.merge(
issues: issues,
template: model.template
)
end
|
#filter_values ⇒ Object
37
38
39
|
# File 'app/models/workarea/search/admin/catalog_product.rb', line 37
def filter_values
model.filters.values.flatten
end
|
#inconsistent_variant_details? ⇒ Boolean
90
91
92
93
|
# File 'app/models/workarea/search/admin/catalog_product.rb', line 90
def inconsistent_variant_details?
details = model.variants.map(&:details).flat_map(&:keys).uniq
model.variants.any? { |v| (details - v.details.keys).present? }
end
|
#issues ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'app/models/workarea/search/admin/catalog_product.rb', line 62
def issues
result = []
result << I18n.t('workarea.alerts.issues.no_images') if model.images.blank?
result << I18n.t('workarea.alerts.issues.no_description') if model.description.blank?
result << I18n.t('workarea.alerts.issues.no_variants') if model.variants.blank?
result << I18n.t('workarea.alerts.issues.no_categories') if Workarea::Categorization.new(model).blank?
result << I18n.t('workarea.alerts.issues.sku_missing_price') if sku_without_price?
result << I18n.t('workarea.alerts.issues.low_inventory') if low_inventory?
result << I18n.t('workarea.alerts.issues.variants_missing_details') if variant_missing_details?
result << I18n.t('workarea.alerts.issues.inconsistent_variant_details') if inconsistent_variant_details?
result
end
|
#jump_to_position ⇒ Object
41
42
43
|
# File 'app/models/workarea/search/admin/catalog_product.rb', line 41
def jump_to_position
3
end
|
#jump_to_search_text ⇒ Object
30
31
32
33
34
35
|
# File 'app/models/workarea/search/admin/catalog_product.rb', line 30
def jump_to_search_text
[
model.id, model.name, model.skus, variant_names,
category_ids, 'product'
].flatten
end
|
#jump_to_text ⇒ Object
26
27
28
|
# File 'app/models/workarea/search/admin/catalog_product.rb', line 26
def jump_to_text
"#{model.name} (#{model.id})"
end
|
#keywords ⇒ Object
22
23
24
|
# File 'app/models/workarea/search/admin/catalog_product.rb', line 22
def keywords
super + model.skus + category_ids
end
|
#low_inventory? ⇒ Boolean
82
83
84
|
# File 'app/models/workarea/search/admin/catalog_product.rb', line 82
def low_inventory?
Inventory::Collection.new(model.skus).low_inventory?
end
|
#search_text ⇒ Object
15
16
17
18
19
20
|
# File 'app/models/workarea/search/admin/catalog_product.rb', line 15
def search_text
[
model.id, model.name, model.skus, variant_names,
category_ids, filter_values, 'product'
].flatten
end
|
#sku_without_price? ⇒ Boolean
77
78
79
80
|
# File 'app/models/workarea/search/admin/catalog_product.rb', line 77
def sku_without_price?
pricing_skus = Pricing::Sku.any_in(id: model.skus).map(&:id)
model.skus.any? { |s| !s.in?(pricing_skus) }
end
|
#status ⇒ Object
7
8
9
10
11
12
13
|
# File 'app/models/workarea/search/admin/catalog_product.rb', line 7
def status
if model.active?
'active'
else
'inactive'
end
end
|
#variant_missing_details? ⇒ Boolean
86
87
88
|
# File 'app/models/workarea/search/admin/catalog_product.rb', line 86
def variant_missing_details?
model.variants.any? { |v| v.details.blank? }
end
|
#variant_names ⇒ Object
58
59
60
|
# File 'app/models/workarea/search/admin/catalog_product.rb', line 58
def variant_names
model.variants.map(&:name)
end
|