5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/controllers/gemgento/magento/product_attributes_controller.rb', line 5
def update
data = params[:data]
unless ProductAttribute.ignored.include?(data[:attribute_code])
@product_attribute = ProductAttribute.find_or_initialize_by(magento_id: params[:id])
@product_attribute.magento_id = data[:attribute_id]
@product_attribute.code = data[:attribute_code]
@product_attribute.frontend_input = data[:frontend_input]
@product_attribute.default_value = data[:default_value]
@product_attribute.scope = data[:scope]
@product_attribute.is_unique = data[:is_unique].to_i == 1 ? true : false
@product_attribute.is_required = data[:is_required].to_i == 1 ? true : false
@product_attribute.is_configurable = data[:is_configurable].to_i == 1 ? true : false
@product_attribute.is_searchable = data[:is_searchable].to_i == 1 ? true : false
@product_attribute.is_visible_in_advanced_search = data[:is_visible_in_advanced_search].to_i == 1 ? true : false
@product_attribute.is_comparable = data[:is_comparable].to_i == 1 ? true : false
@product_attribute.is_used_for_promo_rules = data[:is_used_for_promo_rules].to_i == 1 ? true : false
@product_attribute.used_in_product_listing = data[:used_in_product_listing].to_i == 1 ? true : false
@product_attribute.save
set_options(@product_attribute, data[:options]) unless data[:options].nil?
if @product_attribute.frontend_input == 'media_image'
API::SOAP::Catalog::ProductAttributeMedia.fetch_all_media_types
end
end
render nothing: true
end
|