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 に答える