Magento评论在php中显示的是摘要评级,而不是项目评级


Magento reviews are showing summary-rating instead of rating-items in php

在我的Magento商店里,顾客在3个类别(即价格)中评论我的产品。但是当我打印这些评级时,它只显示一个摘要,而不是这3个类别(见代码)。

<?php
    //from http://www.exploremagento.com/magento/run-magento-code-outside-of-magento.php
    require_once '../app/Mage.php';
    umask(0);
    Mage::app('default'); 
    $review = Mage::getModel('review/review');
$collection = $review->getProductCollection();
$collection
        ->addAttributeToSelect('*')
        ->getSelect()
                ->limit(5)
                ->order('rand()');
$review->appendSummary($collection);
foreach($collection as $product) {
        //var_dump($product->debug());
}
/* To get (what I assume is) 'star' rating. */ 
$ratingSummary = $product->getRatingSummary();
$starRating = $ratingSummary['rating_summary']; 
echo $starRating . "<br/>"; 
?> 

我怎样才能得到所有的评分而不是摘要?

我在helper对象中创建了这个函数,只是为了显示平均产品评级(也是3个类别)的简单html。希望对你有帮助。

public function getRatingHtml($product_id) {
        $store_id = Mage::app()->getStore()->getId();
        $query = "
        SELECT 
            ROUND(AVG(`percent_approved`)) as `rating`
        FROM 
            `rating_option_vote_aggregated` 
        WHERE 
            `entity_pk_value` = {$product_id}
            AND 
            `store_id` = {$store_id}";
        $read = Mage::getSingleton('core/resource')->getConnection('core_read');
        $rating = $read->query($query)->fetch();
        $html = "
        <a href='"/review/product/list/id/{$product_id}/'" class='"rating-box-link'">
        <span class='"rating-box'">
        <span class='"rating'" style='"width: {$rating['rating']}%;'"></span>
        </span>
        </a>";
        return $html;
    }