1

我希望在 magento 的产品页面的侧边栏中显示产品的最新评论(可能是 3 或 4)。

显示评论的前 10 或 15 个单词、星号栏和评论页面的链接以查看所有评论。

非常感谢任何建议或指示,

谢谢,

约翰尼

4

2 回答 2

4

正如 ElGabby 所说,创建一个扩展将是可行的方法。

但是您可以通过编辑当前布局来做到这一点。

转到 /app/design/frontend/default/[your theme]/layout/ 或 /app/design/frontend/base/[your theme]/layout/ 中的文件 catalog.xml

找到部分:

<catalog_product_view>

在那里你有一个类似的部分:

<reference name="right">

在该部分中添加:

<block type="review/product_view" name="right.rewiev" template="review/rightbar.phtml" />

我的示例中的部分如下所示:

<reference name="right">
        <block type="review/product_view" name="right.rewiev" template="review/rightbar.phtml" />
        <block type="catalog/product_list_related" name="catalog.product.related" before="-" template="catalog/product/list/related.phtml"/>
    </reference>

保存文件并在以下位置创建一个新文件:/app/design/frontend/default/[your theme]/design/review/rightbar.phtml

该文件的内容类似于:

<?php $collection = $this->getReviewsCollection(); ?>
<?php if(count($collection) > 0):?>
<?php foreach ($collection as $rating):?>

    <?php echo $rating->title //title of the rewiev?>

    <?php echo $rating->detail //content of the rewiev?>
    <?php echo $rating->created_at //data rewiev is created?>
<?php endforeach;?>
<?php endif;?>
于 2011-06-27T13:08:16.967 回答
1
  • 我会创建一个扩展。
  • 使用 layout.xml 将应该扩展核心/模板块的块放在产品页面的左侧/右侧边栏中
  • 在该块类中,您应该具有将从数据库中检索您希望显示的评论的方法。所以比如说你需要一个方法 getReviews()
  • 在模板中调用 $this->getReviews() 并迭代结果并根据需要显示评论。星号栏可能有点麻烦,但是如果您查看使用它们的其他模板文件,您应该能够了解它的要点:)

HTH :)

于 2011-06-27T12:49:32.173 回答