Magento Get most popular products in a category
Magento get most popular products in any specified category using below code, you can show them in the sidebar of product detail page to let your visitors know the popularity of the products for that category.
$category = Mage::getModel(‘catalog/category’)->load($categoryId);
$products = Mage::getResourceModel(‘reports/product_collection’)
->addOrderedQty() //total number of quantities ordered
->addAttributeToSelect(‘*’) //get all attributes
->setOrder(‘ordered_qty’, ‘desc’) //most ordered quantity products first
->addCategoryFilter($category);