I managed to overwrite the Mage/Catalog/Model/Config.php and make a method that adds a new sorting option called "Sort By Top Sellers".
I also added a where statement where I can get data from last month but the collection doesn't output all the products, only the ones buyed in the last month (I need to sort all the products, not only the ones from last month).
The query outputs correct without the where statement.
Any idea on how to solve this ?
public function sortByTopSelling($dir){
$today = time();
$last = $today - (60*60*24*30);
$from = date("Y-m-d H:i:s", $last);
$to = date("Y-m-d H:i:s", $today);
$this->getSelect()->joinLeft('sales_flat_order_item AS order_item','e.entity_id = order_item.product_id',
'SUM(order_item.qty_ordered) AS ordered_qty')->where('`order_item`.`created_at` > "'.$from.'"')->group('e.entity_id')->order('ordered_qty DESC');
}