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

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 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 at 6:11

2 Answers 2

up vote 3 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 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 at 8:29
    
ok thanks...... :) –  Mr_Green Apr 2 at 8:42

Maybe this is not obvious but ratings and reviews have no connection at all even though they are entered in the same form.

And there are no legitimate way to connect them as no submission timestamp is stored for rating (unless you want to extend the core functionality).

share|improve this answer

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.