Get most viewed products of current product categorywise in magento
$storeId = Mage::app()->getStore()->getId();
$category_ids = $_product->getCategoryIds();
$products = Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*')
->addAttributeToFilter('category_ids',array('finset'=>$category_ids))
->setStoreId($storeId)
->addStoreFilter($storeId)
->addViewsCount()
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
foreach($products as $product){
echo $product->getName();
echo $product->getPrice();
}