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
|
# File 'app/controllers/gemgento/magento/categories_controller.rb', line 5
def update
@category = Category.find_or_initialize_by(magento_id: params[:id])
data = params[:data]
@category.magento_id = data[:category_id]
@category.is_active = data[:is_active].to_i == 1 ? true : false
@category.position = data[:position]
@category.parent = Category.find_by(magento_id: data[:parent_id]) unless data[:parent_id].nil?
@category.name = data[:name]
@category.url_key = data[:url_key]
@category. = data[:include_in_menu]
@category.sync_needed = false
if data.key? :image
begin
@category.image = magento_image(data[:image][:value])
rescue
@category.image = nil
end
end
@category.save
set_stores(data[:store_ids], @category)
set_products(data[:products], @category) unless data[:products].nil?
render nothing: true
end
|