Actually we have two group of customers. Both are having ability to see different products. But in the product page at the reviews section, for both customers, for ratings they should be able to see the rating of both products compinely.

For example:

Main product sku is 'mainsku' -> it is for normal group of cutomers then Other product sku is 'mainsku_CGG' -> it is for special group of

In both products's rating. Customers should be able to the rating as combined and calculated percentage rating of both.

mainsku->100% rating mainsku_CGG -> 80% rating

So in product page rating should be 90% (Average of two), and number of ratings also should be get added.

I don't know how to change the ratings collection here. Can anyone help here?

1 Answer 1


you can do it if you know the product ids of both

$reviews = Mage::getModel('review/review')->getResourceCollection()
    ->addEntityFilter('product', $product_id)
     * Getting average of ratings/reviews

    $avg = 0;
    $ratings = array();
    if (count($reviews) > 0) 
        foreach($todalRevies as $allreviews)
            foreach ($reviews->getItems() as $review)
                foreach( $review->getRatingVotes() as $vote )
                    if($vote->getReviewId() ==$allreviews['review_id'])

                    $ratings[] = $vote->getPercent();

            $avg = array_sum($ratings)/count($ratings);

I hope this help you

  • But here, how to combine both product's rating?
    – SIBHI S
    Commented Aug 11, 2015 at 6:48
  • Have to do the same for the second product and want to find the average?
    – SIBHI S
    Commented Aug 11, 2015 at 6:49
  • yes you have to calculate for both and find the average Commented Aug 11, 2015 at 6:50

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.