Thursday, May 10, 2012

How to echo the number of reviews on the product page?

I have found out that this code finaly works when inserting into catalog/product/view.phtml
<?php
   $reviewData 
Mage::getModel('review/review/summary');
   echo 
'number of reviews: ' $reviewData->getTotalReviews($_product->getId());

   $reviews = Mage::getModel('review/review')->getCollection()
     ->addStoreFilter(Mage::app()->getStore()->getId())
     ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
     ->addEntityFilter('product', $_product->getId())
     ->setDateOrder();


     foreach ($reviews->getItems() as $review){
     echo $review->getTitle().'<br>';
     echo $review->getNickname().'<br>';
     echo $review->getDetail().'<br>';

     }
?>


                           
                           
                             

No comments:

Post a Comment