mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-20 14:54:15 +01:00
(bug) order by price with unset prices
In product ordering, consider NULL prices (no price has been defined) as 0, to order those products as lowest prices items
This commit is contained in:
parent
1c5abf663d
commit
e687e8ad02
@ -126,7 +126,11 @@ class ProductService
|
||||
key ||= 'created_at'
|
||||
order ||= 'desc'
|
||||
|
||||
products.order(key => order)
|
||||
if key == 'amount'
|
||||
products.order("COALESCE(amount, 0) #{order.upcase}")
|
||||
else
|
||||
products.order(key => order)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user