路径
app\code\local\WeiCot\DetailedReview\Block\Helper.php
<?php
class WeiCot_DetailedReview_Block_Helper extends Mage_Review_Block_Helper
{
/**
* @inherit
*/
public function __construct()
{
if (Mage::getStoreConfig('detailedreview/settings/enable')) {
$this->_availableTemplates['default'] = 'detailedreview/review/helper/summary.phtml';
$this->_availableTemplates['short'] = 'detailedreview/review/helper/summary_short.phtml';
}
parent::__construct();
}
// 我重写了这个方法 Mage_Review_Block_Helper getSummaryHtml()
public function getSummaryHtml($product, $templateType, $displayIfNoReviews)
{
// pick template among available
if (empty($this->_availableTemplates[$templateType])) {
$templateType = 'default';
}
$this->setTemplate($this->_availableTemplates[$templateType]);
$this->setDisplayIfEmpty($displayIfNoReviews);
if (!$product->getRatingSummary()) {
Mage::getModel('review/review')
//->getEntitySummary($product, Mage::app()->getStore()->getId()); 将 Mage::app()->getStore()->getId() 修改成匹配
->getEntitySummary($product,"*");
}
$this->setProduct($product);
return $this->toHtml();
}
}
还有一些其他 小修改 大致思路 就是将 单店铺用 “*” 匹配
修改完后 我发现产品列表页 没有达到预期的效果 并没有显示出所有评
然后我追踪 并阅读了一下源码 发现调用貌似也是上面的方法 但不知道在哪里被覆盖了 寻找无果
我直接在输出的 地方覆盖了 这个方法
文件位置
app\design\frontend\default\default\template\detailedreview\review\helper\summary_short.phtml
<?php
//$reviewSummary = Mage::getModel('review/review_summary');
//$redata=$reviewSummary->setStoreId("0")->load($this->getProduct()->getId())->getRatingSummary();
//print_r($redata);
//$ratingSummary = $this->getProduct()->getRatingSummary();
//print_r($ratingSummary->getData()['reviews_count']);
//$reviewHelper = $this->getLayout()->createBlock('review/helper');
//print_r($reviewHelper->getSummaryHtml(, 'default'));
?>
<?php
//直接在这里调用函数 覆盖以前的数据
Mage::getModel('review/review')->getEntitySummary($this->getProduct(), "*");
?>
<?php if ($this->getReviewsCount()): ?>
<div class="ratings">
<?php if ($this->getRatingSummary()):?>
<div class="rating-box">
<div class="rating" style="width:<?php
echo $this->getRatingSummary()
?>%"></div>
</div>
<?php endif;?>
<span class="amount"><?php echo $this->__('(%d)', $this->getReviewsCount()) ?></span>
</div>
<?php else: ?>
<div class="rating-box-none">
<div class="rating" style="width:100%"></div>
</div>
<?php endif; ?>
至此完成 所有调用修改
转载请注明:(●--●) Hello.My Weicot » Magneto 调出单个产品的所有评论(包含不同店铺 语言的评论)


