Get cat­e­gory prod­ucts or­dered by num­ber of sales

This snippet is useful if you want to know which products are the bestsellers, this can be used on custom reports, lists, etc.
$catId= 2; //Change this to your Category ID

//Lets load up that category
$category = Mage::getModel('catalog/category')->load($catId);

$products = Mage::getResourceModel('reports/product_collection')
		->addOrderedQty()
		->addAttributeToSelect('*')
		->setOrder('ordered_qty', 'desc')
		->addCategoryFilter($category);

Related Posts:

, ,

Comments (0)

Post A Comment