Question

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.

Was it helpful?

Solution

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);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top