0

I am trying to get all the reviews for current product detail page which are 5 star rated.How are we suppose to filter ?

 $storeId = Mage::app()->getStore()->getId();
            $_product = $this->product();
             $summaryData = Mage::getModel('review/review_summary')
                    ->setStoreId($storeId)
                    ->load($_product->getId());
1
<?php
$_product = $this->getProduct();

$reviews = Mage::getModel('review/review')->getResourceCollection();

    $summaryData = $reviews->addStoreFilter(Mage::app()->getStore()->getId())
    ->addEntityFilter('product', $_product->getId())
    ->addStatusFilter( Mage_Review_Model_Review::STATUS_APPROVED )
    ->setDateOrder()
    ->addRateVotes();

foreach($summaryData as $child){

    $_votes = $child->getRatingVotes();

    if (count($_votes)){

        foreach ($_votes as $_vote){
            if($_vote->getPercent() == 100){
                echo $child->getData('review_id'); 
            }   
        }
    }
}

Using above code you can filter 5star review.

| improve this answer | |
  • ur code is returning me all the reviews of that product irrespective of their rating – Akash Mar 4 '16 at 21:00
  • Its filtering collection which have 5 star by if($_vote->getPercent() == 100){ . Are you using star on review? – Prashant Valanda Mar 4 '16 at 21:09
  • yes i do i have 2 reviews with 4 stars i.e 80 and 1 with 3 star i.e 60. I used with if($_vote->getPercent() == 80). It returned me all 3 reviews id. – Akash Mar 4 '16 at 21:17
  • Update code try with it – Prashant Valanda Mar 4 '16 at 21:33

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.