I’d like to display a view count on a category listing page in Magento. This data looks like it used to be accessible via reports/product_collection but I can’t find a way to access it correctly.
I’d basically like to supply a product id and get the view count of the said product returned to me.
You can get the view count through the
Mage_Reports_Model_Resource_Product_Collectionmodel.Each item in the collection is a
catalog/productinstance with a views property set, so you can use$product->getViews()to get the count.If you don’t want to load the whole product model and only require the view count, you can get it like this:
This gives you an array, the keys are the product ids and the values are the view counts.