Show recent_viewed products on product Page

2019-04-12 15:32发布

The Current default functionality of magento is that it shows the recently viewed products on right side of category page. Now I would like to display the same content on at the bottom of product page. the phtml file used is named at location as

frontend/base/default/template/reports/product_viewed.phtml.

Is there any simple way to do it ?

4条回答
祖国的老花朵
2楼-- · 2019-04-12 16:15

You can use an extension:

Atwix Recently Viewed Products Bar

It is free and will show all recent viewed products in footer.

查看更多
冷血范
3楼-- · 2019-04-12 16:16

Show recently viewed product anywhere with this code.

echo $this->getLayout()->createBlock("reports/product_viewed")->setTemplate("reports/product_viewed.phtml")->toHtml();
查看更多
戒情不戒烟
4楼-- · 2019-04-12 16:22

In your theme you will modify the catalog.xml file (/app/design/frontend/{your theme}/default/layout/catalog.xml). Find the following section and add a block call for the template towards the bottom of the content reference.

<catalog_product_view translate="label">
 <reference name="content">
  <block type="reports/product_viewed" name="product.recently.viewed" as="product_recently_viewed" template="reports/product_viewed.phtml"/>
 </reference>
</catalog_product_view>

Then you need to modify your theme for where you want the block to show up. In /app/design/frontend/{your theme}/default/template/catalog/product/view.phtml add the following line where you want the Recently Viewed products to show up.

<?php echo $this->getChildHtml('product_recently_viewed') ?>

That will get it to show but you may need to tweak the template a bit because it is designed for the left column and may not layout properly if you insert it into the middle one.

查看更多
祖国的老花朵
5楼-- · 2019-04-12 16:34

You have two options. You can use layout XML to make the right.reports.product.viewed block a child of the product.info block and a getChildHtml() call to the catalog/product/view.phtml template, or you can change the product page to a 2column-right layout.

查看更多
登录 后发表回答