我一直试图从社区扩展中覆盖结帐控制器2小时,但仍无效。
我的自定义模块已激活。 试图重写(社区/ Manv / Ajaxcoupon / controllers / Indexcontroller.php) 这是我的控制器。
require_once 'Manv/Ajaxcoupon/controllers/IndexController.php';
class Name_Promocode_CartController extends Manv_Ajaxcoupon_IndexController
{
public function customcouponPostAction(){
die('custom');
}
public function couponPostAction()
{
die('We are in');
}
这是我的config.xml
<?xml version="1.0"?>
<config>
<modules>
<Name_Promocode>
<version>1.0.0</version>
</Name_Promocode>
</modules>
<frontend>
<routers>
<checkout>
<args>
<modules>
<Name_Promocode before="Manv_Ajaxcoupon">Name_Promocode</Name_Promocode>
</modules>
</args>
</checkout>
</routers>
</frontend>
</config>
删除缓存... 当我在社区模块中放置die()时,我看不到它的错误。但似乎我的模块并没有压倒任何事情。
答案 0 :(得分:0)
//尝试与下面的config.xml代码进行比较。
<config>
<frontend>
<routers>
<checkout>
<args>
<modules>
<name_promocode before="Mage_Tag">Manv_Ajaxcoupon</name_promocode>
</modules>
</args>
</tag>
</routers>
</frontend>
</config>
//替代覆盖控制器代码。
<global>
<!-- This rewrite rule could be added to the database instead -->
<rewrite>
<!-- This is an identifier for your rewrite that should be unique -->
<!-- THIS IS THE CLASSNAME IN YOUR OWN CONTROLLER -->
<customcontactsunique>
<from><![CDATA[#^/contacts/index/#]]></from>
<!--
- mymodule matches the router frontname below
- matches the path to your controller
Considering the router below, "/customcontacts/index/" will be
"translated" to "app/code/local/Amit/Customcontacts/controllers/IndexController.php" (?)
-->
<to>/customcontacts/index/</to>
</customcontactsunique>
</rewrite>
</global>
//比较控制器代码。
require_once(Mage::getModuleDir('controllers','Manv_Ajaxcoupon').DS.'IndexController.php');
class Name_Promocode_CartController extends Manv_Ajaxcoupon_IndexController
{
// some code
}
答案 1 :(得分:0)
试试这个:
<config>
<modules>
<Name_Promocode>
<version>1.0.0</version>
</Name_Promocode>
</modules>
<frontend>
<routers>
<name_promocode>
<use>standard</use>
<args>
<module>Name_Promocode</module>
<frontName>promocode</frontName>
</args>
</name_promocode>
</routers>
</frontend>
<global>
<rewrite>
<name_promocode>
<from><![CDATA[#^/ajaxcoupon/index/#]]></from> <!-- the URL which u want to override-->
<to>/promocode/cart/</to> <!-- destination url -->
</name_promocode>
</rewrite>
</global>
</config>
答案 2 :(得分:0)
最后使它适用于此config.xml
<config>
<modules>
<Name_Promocode>
<version>1.0.0</version>
</Name_Promocode>
</modules>
<frontend>
<routers>
<name_promocode>
<use>standard</use>
<args>
<module>Name_Promocode</module>
<frontName>promocode</frontName>
</args>
</name_promocode>
</routers>
</frontend>
<global>
<rewrite>
<name_promocode>
<from><![CDATA[#^/ajaxcoupon/index/#]]></from> <!-- the URL which u want to override-->
<to>/promocode/cart/</to> <!-- destination url -->
</name_promocode>
</rewrite>
</global>
</config>
希望这会对某人有所帮助:D