add checksum for menu sync

This commit is contained in:
Yan
2017-08-23 18:59:23 +06:30
parent 911b941793
commit 55f041a252
5 changed files with 28 additions and 11 deletions

View File

@@ -5,14 +5,14 @@ param_count = item.item_attributes.count
item.item_attributes.each do|attr_id|
menu_attr = MenuItemAttribute.find(attr_id)
if attr_format.count == 0
attr_format.push({ type: menu_attr.attribute_type, value: [] })
attr_format.push({ type: menu_attr.attribute_type, values: [] })
end
attr_format.each do |af|
if menu_attr.attribute_type == af[:type]
af[:value].push(menu_attr.value)
af[:values].push(menu_attr.name)
else
new_attr = {type: menu_attr.attribute_type, value: [ menu_attr.value ] }
new_attr = {type: menu_attr.attribute_type, values: [ menu_attr.name ] }
attr_format.push(new_attr)
end
@@ -29,14 +29,14 @@ param_count = item.item_options.count
item.item_options.each do|opt|
menu_opt = MenuItemOption.find(opt)
if opt_format.count == 0
opt_format.push({ type: menu_opt.option_type, value: [] })
opt_format.push({ type: menu_opt.option_type, values: [] })
end
opt_format.each do |af|
if menu_opt.option_type == af[:type]
af[:value].push(menu_opt.value)
af[:values].push(menu_opt.name)
else
new_attr = {type: menu_opt.option_type, value: [ menu_opt.value ] }
new_attr = {type: menu_opt.option_type, values: [ menu_opt.name ] }
opt_format.push(new_attr)
end