3

I am using Review module to allow customers to set rating to product. I have three different ratings. Then i call ->getRatingSummary() from code\core\Mage\Review\Model\Review\Summary.php to get summary rating from all votes.

What should i do to get summary rating for each my rating? (I have three records in "select * from rating")

I suppose the data for this is stored in

select * from  rating_option_vote_aggregated

in the column [percent].

What method should i call to get summary rating for my each rating? Thank you.

1 Answer 1

6

To get Rating Array Try the Below Code.

$prod=Mage::getSingleton('catalog/product')->load('your Prodouct Id');
$productId = $prod->getId();
$reviews = Mage::getModel('review/review')
            ->getResourceCollection()
            ->addStoreFilter(Mage::app()->getStore()->getId())
            ->addEntityFilter('product', $productId)
            ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
            ->setDateOrder()
            ->addRateVotes();


    if (count($reviews) > 0) {
        foreach ($reviews->getItems() as $review) {
            foreach( $review->getRatingVotes() as $vote ) {
                $ratings[] = $vote->getPercent();
            }
        }
    print_r($ratings);
}

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.