Class: Plugins::Ecommerce::AdminController
- Inherits:
-
CamaleonCms::Apps::PluginsAdminController
- Object
- CamaleonCms::Apps::PluginsAdminController
- Plugins::Ecommerce::AdminController
show all
- Defined in:
- app/controllers/plugins/ecommerce/admin_controller.rb
Instance Method Summary
collapse
Instance Method Details
#index ⇒ Object
3
4
5
|
# File 'app/controllers/plugins/ecommerce/admin_controller.rb', line 3
def index
end
|
#product_attributes ⇒ Object
7
8
9
|
# File 'app/controllers/plugins/ecommerce/admin_controller.rb', line 7
def product_attributes
end
|
#save_product_attributes ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'app/controllers/plugins/ecommerce/admin_controller.rb', line 11
def save_product_attributes
current_site.product_attributes.where.not(id: params[:attribute].keys).destroy_all
params[:attribute].each do |key, values|
if key.include?('new')
group = current_site.product_attributes.create(label: params[:attribute_names][key][:label])
else
group = current_site.product_attributes.find(key)
group.update(label: params[:attribute_names][key][:label])
end
group.values.where.not(id: values.map{|v| v[:id] }).delete_all
values.each do |val|
data = {key: val[:key], label: val[:value], position: val[:position]}
if val[:id].present?
group.values.find(val[:id]).update(data)
else
group.values.create(data)
end
end
end
flash[:notice] = t('.saved_product_attributes', default: 'Attributes Saved')
redirect_to action: :product_attributes
end
|