19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'app/helpers/stores_helper.rb', line 19
def category_item_grouped(items)
h = {}
items.each do |i|
h[i.product_category] ||= {}
h[i.product_category][i] ||= { Store::WARMLYYOURS_US_ID => {}, Store::WARMLYYOURS_CA_ID => {} }
i.store_items.available.with_back_order_quantities.select('store_items.*, (select amount from catalog_items ci where ci.store_item_id = store_items.id order by catalog_id limit 1) as msrp, (select currency_symbol from catalogs c inner join catalog_items ci on ci.catalog_id = c.id where ci.store_item_id = store_items.id order by catalog_id limit 1) as msrp_currency_symbol').each do |si|
h[i.product_category][i][si.store_id] = {
on_hand: si.qty_on_hand,
available: si.qty_available,
backordered: si.qty_backordered,
stock_class: stock_class(si),
non_stock: si.permanent_qty_available.present?,
store_item_id: si.id,
store_id: si.store_id,
item_id: i.id,
msrp: si.msrp,
msrp_currency_symbol: si.msrp_currency_symbol
}
end
end
h
end
|