如何在Magento 1.8中对评论的list.phtml进行评审?

时间:2014-07-09 13:30:39

标签: php magento magento-1.8

如何通过审核list.phtml获取评论?

frontend\base\default\template\review/product/view/list.phtml

在此页面中使用此代码时出现错误,

<?php
// Get the number of reviews of the product on the product page.
$storeId    = Mage::app()->getStore()->getId();

$summaryData = Mage::getModel('review/review_summary')
->setStoreId($storeId)
->load($_product->getId());

/* @var $summaryData Mage_Review_Model_Review_Summary */

/*

array(
['primary_id'] => 147
['entity_pk_value'] => 166
['entity_type'] => 1
['reviews_count'] => 1
['rating_summary'] => 80
['store_id'] => 1
)
*/
//var_dump($summaryData['reviews_count']);
?>

误差,

Fatal error: Call to a member function getId() on a non-object in 

虽然frontend\base\default\template\review/product/view/count.phtml上的点数将始终返回为空

<?php if (!empty($count)):?>
    <a href="#customer-reviews" class="nobr"><?php echo $this->__('%s Review(s)', $count) ?></a>
<?php endif;?>

知道为什么吗?

我的catalog.xml&#39; <catalog_product_view translate="label">

中有代码
           <!-- adding review to the product page -->
            <block type="page/html_pager" name="product_review_list.toolbar">
                <action method="setLimit"><limit>2</limit></action>
            </block>
            <block type="review/product_view_list" name="product.info.product_additional_data" as="product_review" template="review/product/view/list.phtml">
                <block type="core/template" name="product_review_list.count" template="review/product/view/count.phtml" />
                <block type="review/form" name="product.review.form" as="review_form"/>
            </block>
            <!-- adding review to the product page -->

1 个答案:

答案 0 :(得分:3)

请尝试非常简单的代码这对我有用。

?php echo $this->getReviewsSummaryHtml($_product, 'short')?>

它看起来像附加截图。enter image description here