我只需要创建最近的Product View Slider。 所以我想从核心文件中覆盖Reports_Product_Viewed块。 我为此编写了config.xml,但在产品页面上我无法做到这一点。 基本上我想覆盖Reports产品块,并希望为最近的产品滑块添加一些代码。 我的config.xml是
----------------
<?xml version="1.0"?>
<config>
<modules>
<Deepak_Recent>
<version>0.1.0</version>
</Deepak_Recent>
</modules>
<global>
<blocks>
<recent>
<rewrite>
<reports_product_viewed>Deepak_Recent_Block_Product_Viewed</reports_product_viewed>
</recent>
</catalog>
</blocks>
<helpers>
<recent>
<class>Deepak_Recent_Helper</class>
</recent>
</helpers>
</global>
<frontend>
<routers>
<recent>
<use>standard</use>
<args>
<module>Deepak_Recent</module>
<frontName>recent</frontName>
</args>
</recent>
</routers>
<layout>
<updates>
<recent>
<file>recent.xml</file>
</recent>
</updates>
</layout>
</frontend>
</config>
my rewrite block
-----------------
<?php
class Deepak_Recent_Block_Product_Viewed extends Mage_Reports_Block_Product_Viewed{
public function getme(){ echo 'block loaded';}
}
my layout.xml
---------------
<?xml version="1.0"?>
<layout version="0.1.0">
<catalog_product_view>
<reference name="product.info">
<block type="recent/product" name="product.info.recent" template="carousel/products_recent_horizontal.phtml"/>
</reference>
</catalog_product_view>
</layout>
and alst my phtml file
-----------------
<?php
echo $this->getme();exit;
?>
答案 0 :(得分:0)
您的config.xml
文件应为
<config>
<modules>
<Deepak_Recent>
<version>0.1.0</version>
</Deepak_Recent>
</modules>
<global>
<blocks>
<reports> <!-- Changes here start -->
<rewrite>
<product_viewed>Deepak_Recent_Block_Product_Viewed</product_viewed>
</rewrite>
</reports> <!-- Changes here end -->
</blocks>
<helpers>
<recent>
<class>Deepak_Recent_Helper</class>
</recent>
</helpers>
</global>
<frontend>
<routers>
<recent>
<use>standard</use>
<args>
<module>Deepak_Recent</module>
<frontName>recent</frontName>
</args>
</recent>
</routers>
<layout>
<updates>
<recent>
<file>recent.xml</file>
</recent>
</updates>
</layout>
</frontend>
</config>
实际上问题在
<blocks>
<reports> <!-- Changes here start -->
<rewrite>
<product_viewed>Deepak_Recent_Block_Product_Viewed</product_viewed>
</rewrite>
</reports> <!-- Changes here end -->
</blocks>