I need to sort products on catalog page by ordered quantity.
What is the best way to do it?
I know that table sales_order_item
contains this data, but I think direct SQL queries is bad practice (like SELECT SUM(qty_ordered) FROM sales_order_items WHERE product_id = {$product id}
and then sort it).
So I want to find good solution.
Thanks!
Best Answer
I've found solution myself: