ย้าย Recently Viewed Products ไปยังใต้สินค้าใน magento
Recently Viewed Products ที่มีไว้แสดงสินค้าที่ลูกค้าดูมาแล้วมาอะไรบ้าง โดยปกติมันจะขึ้นอยู่ทางด้านขวามือแต่ถ้าเราอยากให้มันแสดงอยู่ใต้สินค้าเราจะทำได้ยังไง
พอดีมีลูกค้ามาสอบถามผมก็เลยไปหาคำตอบมาให้และพอทำได้ก็เลยมาเขียนลงใน KTW ดีกว่ามาดูวิธีทำกันดีกว่า
1. แก้ไขไฟล์ app/design/frontend/default/default/layout/reports.xml ให้เป็นดังนี้
<layout version="0.1.0"> <default> <reference name="right"> <!-- <block type="reports/product_viewed" before="right.permanent.callout" name="right.reports.product.viewed" template="reports/product_viewed.phtml" /> --> </reference> </default> <catalog_product_view> <reference name="content"> <reference name="product.info"> <reference name="product.recently.viewed"> <block type="reports/product_viewed" before="right.permanent.callout" name="right.reports.product.viewed" template="reports/product_viewed.phtml" /> </reference> </reference> </reference> </catalog_product_view> </layout>
2. สร้าง block ใหม่ใน app/design/frontend/default/default/layout/catalog.xml โดยนำโค็ดด้านล่าง
<!-- product_viewed add -->
<block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
<!-- product_viewed add -->
ไปใส่ไว้ใต้
<!-- Product view --> <catalog_product_view> <!-- Mage_Catalog --> <reference name="root"> <action method="setTemplate"><template>page/2columns-right.phtml</template></action> </reference> <reference name="head"> <action method="addJs"><script>varien/product.js</script></action> <action method="addItem"><type>js_css</type><name>calendar/calendar-win2k-1.css</name><params/><!--<if/><condition>can_load_calendar_js</condition>--></action> <action method="addItem"><type>js</type><name>calendar/calendar.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action> <action method="addItem"><type>js</type><name>calendar/calendar-setup.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action> </reference> <reference name="content"> <block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml"> …
3. ต่อมาแก้ไขไฟล์ app/design/frontend/default/default/template/catalog/product/view.phtm นำโค็ดด้านล่าง
<?php echo $this->getChildHtml('product_recently_viewed') ?>
ไปวางไว้เหนือ
<?php echo $this->getChildHtml('upsell_products') ?>
แค่นี้ละครับ Recently Viewed Products ก็จะมาอยู่บริเวณใต้สินค้าเราแล้ว ถ้าจะแก้ไข layout ของมันให้ไปแก้ที่ไฟล์ app/design/frontend/default/default/template/reports/product_viewed.phtml
Thank : http://www.magentocommerce.com/boards/viewthread/62096/
บทความแนะนำ

