Magento how to get rating star by review id

enter image description here

I used the following code

$ratingCollection = Mage::getModel('rating/rating_option_vote')

     $ratings = array();
     foreach($ratingCollection as $item){

but I am getting array summary as 12, 15 but I need %


1 Answer 1


The rating_option_vote table saves to vote option for a particular rating type.

This table has review_id as the foreign key which references to review table.

Please check screenshots for reference.

enter image description here

enter image description here

Update: Code for getting ratings per review:

$reviewcollection = Mage::getModel('review/review')->getCollection()
        $_items = $reviewcollection;
// echo "<pre>";print_r($_items->getData());echo "</pre>";
        foreach ($_items as $_review) {
            $_votes = $_review->getRatingVotes();
            if (count($_votes)) {
                foreach ($_votes as $_vote) {
                    echo $this->escapeHtml($_vote->getRatingCode());
                    echo "<br/>";
                    echo $_vote->getPercent();

Update: You can also try below code:

$votesCollection = Mage::getModel('rating/rating_option_vote')
// echo "<pre>";print_r($votesCollection);echo "</pre>";
    foreach ($votesCollection as $vote) {
        # code...
        echo "<pre>";print_r($vote);echo "</pre>";
  • can you please check the updated question, thanks i used the above code
    – Raghu
    Commented Mar 5, 2018 at 9:40
  • @Raghu, please see my updated answer. Commented Mar 5, 2018 at 12:42

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.