Show recent_viewed products on product Page

↘锁芯ラ 提交于 2019-12-04 15:06:56

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.

Show recently viewed product anywhere with this code.

echo $this->getLayout()->createBlock("reports/product_viewed")->setTemplate("reports/product_viewed.phtml")->toHtml();

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.

vritika

You can use an extension:

Atwix Recently Viewed Products Bar

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!