Skip to main content
added 373 characters in body
Source Link
Jigs Parmar
  • 2.4k
  • 2
  • 15
  • 33

you use below script to get all reveiew and rating .

 <?php
require_once('app/Mage.php');
Mage::app();

$_product=Mage::getModel('catalog/product')->load(1);

$productId = $_product->getId();
$reviews = Mage::getModel('review/review')
                ->getResourceCollection()
                ->addStoreFilter(Mage::app()->getStore()->getId())
                ->addEntityFilter('product', $productId)
                ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
                ->setDateOrder()
                ->addRateVotes();

$avg = 0;
$ratings = array();
if (count($reviews) > 0) {
    foreach ($reviews->getItems() as $review) {
        foreach( $review->getRatingVotes() as $vote ) {
            Mage::log($reviews'2 if');
            Mage::log($vote->getData());
            $ratings[] = $vote->getPercent();
        }
    }
    
    $avg = array_sum($ratings)/count($ratings);
}
echo 'avg'.$avg;

?>

you use below script to get all reveiew and rating .

<?php
require_once('app/Mage.php');
Mage::app();

$_product=Mage::getModel('catalog/product')->load(1);

$productId = $_product->getId();
$reviews = Mage::getModel('review/review')
                ->getResourceCollection()
                ->addStoreFilter(Mage::app()->getStore()->getId())
                ->addEntityFilter('product', $productId)
                ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
                ->setDateOrder()
                ->addRateVotes();
                
Mage::log($reviews->getData());

?>

you use below script to get all reveiew and rating .

 <?php
require_once('app/Mage.php');
Mage::app();

$_product=Mage::getModel('catalog/product')->load(1);

$productId = $_product->getId();
$reviews = Mage::getModel('review/review')
                ->getResourceCollection()
                ->addStoreFilter(Mage::app()->getStore()->getId())
                ->addEntityFilter('product', $productId)
                ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
                ->setDateOrder()
                ->addRateVotes();

$avg = 0;
$ratings = array();
if (count($reviews) > 0) {
    foreach ($reviews->getItems() as $review) {
        foreach( $review->getRatingVotes() as $vote ) {
            Mage::log('2 if');
            Mage::log($vote->getData());
            $ratings[] = $vote->getPercent();
        }
    }
    
    $avg = array_sum($ratings)/count($ratings);
}
echo 'avg'.$avg;

?>
Source Link
Jigs Parmar
  • 2.4k
  • 2
  • 15
  • 33

you use below script to get all reveiew and rating .

<?php
require_once('app/Mage.php');
Mage::app();

$_product=Mage::getModel('catalog/product')->load(1);

$productId = $_product->getId();
$reviews = Mage::getModel('review/review')
                ->getResourceCollection()
                ->addStoreFilter(Mage::app()->getStore()->getId())
                ->addEntityFilter('product', $productId)
                ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
                ->setDateOrder()
                ->addRateVotes();
                
Mage::log($reviews->getData());

?>