jorjdaniel
jorjdaniel

Reputation: 850

Magento sort by sold products in last 30 days

How can I sort products (in categories) by ordered quantity in last 30 days.

I found this tutorial but it's not what I really want.

Upvotes: 0

Views: 960

Answers (1)

Lucas Moeskops
Lucas Moeskops

Reputation: 5443

My suggestion would be to create a script that calculates these data.

The sales_flat_order_item table contains the information you needs I think (all items ordered with quantity and date among others). Put the result of this calculation (ordered_quantity integer) into a custom new attribute on the product ('popularity'). The script can be run via a cron job to prevent the customer from suffering from it.

Then all you need to do is make this attribute used for sorting and set it as available sorting for the category as well as as default sorting for products (in Magento configuration).

Upvotes: 1

Related Questions