How to get product rating and review in magento

/**
* Getting reviews collection object

*/
$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();
}
}
$avg = array_sum($ratings)/count($ratings);
}

8 comments:

  1. You can also try a readymade extension called magento product reviews extension that lets the user to share their reviews and rating and anyone can see average rating on every product page.

    ReplyDelete
  2. Use Our Product Ratings and Reviews Software Increase sales and leads with Cus-tomers Reviews and Testimonials on Product and service. Improve Customers confi-dence with getting selections and reduce product returns.
    Product Reviews and Ratings

    ReplyDelete
  3. Customer Reviews and Feedbacks is an important source of information to identify the service provider’s performance. It measures the satisfaction level of the customers and ensures maintenance of positive relationship with customers. It helps to detect the root causes of customer’s dissatisfaction thereby helping in customer retention and improving the profit margins.
    Rating and Review Software

    ReplyDelete
  4. Review and Rating Software increase customer ’ s confidence, and can significantly increase sales. Online ratings and reviews provide incredible value and benefits that businesses cannot afford to ignore. Such system help businesses to establish credibility and improve their search engine visibility.

    Customers Ratings and Reviews

    ReplyDelete
  5. Hi,

    This is Great Coding Awesome information.. Thank you very much for sharing..

    Wedding Websites | Web Development India

    ReplyDelete
  6. Magento Integration is explained very discreetly and effectively . thanks

    ReplyDelete
  7. I do agree with all the ideas you have presented in your post. They’re really convincing and will certainly work. Still, the posts are very short for newbies. Could you please extend them a little from next time?..Keep this great work
    magento development company in bangalore 

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete