Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my requirement, I have a review id with me by using that, I am getting complete information of that specific review by using the following code:

$review = Mage::getModel('review/review')->load($reviewId);

The above code is giving complete information but not just ratings. When I did Mage::log($review->getData()), I can see the following information which is clearly showing absence of ratings.

(
    [review_id] => 676
    [created_at] => 2014-01-31 15:19:24
    [entity_id] => 1
    [entity_pk_value] => 669
    [status_id] => 1
    [detail_id] => 675
    [store_id] => 1
    [title] => Hulk@hell.com
    [location] => Hulk mania
    [view_type] => 1
    [detail] => Hulk smash
    [nickname] => Hulk
    [customer_id] => 
    [course] => 
    [ystart] => 0
    [yend] => 0
    [stores] => Array
        (
            [0] => 0
            [1] => 1
        )

)

Please help

EDIT: I tried this which is giving all the three rating values but I was looking for percentage. and even the code is bigger and seems to be degrading performance.

$review = Mage::getModel('review/review')
                ->load($reviewId);

$data = $review->getData();
$votes = Mage::getModel('rating/rating_option_vote')
        ->getResourceCollection()
        ->setEntityPkFilter($data['entity_pk_value'])
        ->addFilter('review_id', $reviewId)
        // ->setStoreFilter(Mage::app()->getStore()->getId())
        ->load();
share|improve this question
    
possible duplicate of Get ratings related to a product – moose Apr 2 '14 at 6:05
    
@moose that is getting ratings related to a product. I am asking here getting ratings related to a review. I would have used that link if I knew product id. but here I know review id. or am I being confused? – Mr_Green Apr 2 '14 at 6:11
up vote 5 down vote accepted

You can get the vote collection related to a review via the following code snippet. This will return you the content of the table rating_option_vote including the rating_id if that is what you are looking for.

$votesCollection = Mage::getModel('rating/rating_option_vote')
    ->getResourceCollection()
    ->setReviewFilter($reviewId)
    ->setStoreFilter(Mage::app()->getStore()->getId())
    ->load();
share|improve this answer
    
This is giving me the same three types of ratings with values but not a average percentage of the three. Please check my edit. – Mr_Green Apr 2 '14 at 8:15
    
@Mr_Green then sadly I think you need to join to the aggregated table with the rating id and product id you have just found from the vote collection :( – David Manners Apr 2 '14 at 8:29
    
ok thanks...... :) – Mr_Green Apr 2 '14 at 8:42
    
I wonder what went through those guys' heads when they didn't include the ratings in Mage::getModel('review/review'). Every single store out there wants those stars but you have to go through an extra step to get them. – Claudiu Creanga Jan 28 at 14:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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