0

What is the best way to get a collection of product reviews, and retrieve the name and rating number from this collection?

thx.

3

Take a look at How to get product rating and review in magento

$productId = $product->getId();
$reviews = Mage::getModel('review/review')
                ->getResourceCollection()
                ->addStoreFilter(Mage::app()->getStore()->getId()) 
                ->addEntityFilter('product', $productId)
                ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
                ->setDateOrder()
                ->addRateVotes();
/**
* Getting average of ratings/reviews
*/
$avg = 0;
$ratings = array();
if (count($reviews) > 0) {
   foreach ($reviews->getItems() as $review) {
      foreach( $review->getRatingVotes() as $vote ) {
        $ratings[] = $vote->getPercent();
           ..
  • That returns the averaged sum of all ratings. I want to get the individual rating of a single review. – hownowbrowncow Nov 4 '14 at 19:51
  • 1
    Did you try $review->getData(); or $vote->getData()? – Renon Stewart Nov 4 '14 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.