0

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

thx.

1 Answer 1

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();
           ..
2
  • That returns the averaged sum of all ratings. I want to get the individual rating of a single review. Commented Nov 4, 2014 at 19:51
  • 1
    Did you try $review->getData(); or $vote->getData()? Commented Nov 4, 2014 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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