Magento的控制器改写规则

Magento的 控制器类 重载是 不同的东西 ,然后 其他 类。 控制器 覆盖 为模型 ,辅助 ,块 覆盖 相同。 我的经验, 在某种程度上 很难 覆盖 控制器 ,你 需要获得 额外 的重写 正则表达式 的确切原因 这将导致 非常 辛苦。 下面是 一些 解释 重写系统 控制器

Customer Account and Address Controller override:

At first create new module and files
1. /app/etc/modules/Yt_Customer.xml
2. /app/code/local/Yt/Customer/etc/config.xml
3. /app/code/local/Yt/Customer/controllers/AccountController.php
4. /app/code/local/Yt/Customer/controllers/AddressController.php

 

<?xml version="1.0"?>
<config>
<modules>
<Yt_Customer>
<version>0.1.0</version>
</Yt_Customer>
</modules>

<frontend>
<routers>
<Yt_customer>
<use>standard</use>
<args>
<module>Yt_Customer</module>
<frontName>customer</frontName>
</args>
</Yt_customer>
</routers>
</frontend>

<global>
<rewrite>
<Yt_customer_account>
<from><![CDATA[#^/account/#]]></from>
<to>/customer/account/</to>
</Yt_customer_account>

<Yt_customer_address>
<from><![CDATA[#^/address/#]]></from>
<to>/customer/address/</to>
</Yt_customer_address>
</rewrite>
</global>
</config>

现在, 你的新 的控制器类 Yt_Customer_AccountController 并定义所有 覆盖方法

class Yt_Customer_AccountController extends Mage_Customer_AccountController
{
// override existing method
public function loginPostAction()
{
// Define new login function. From now magento call this login method instead of existing method
}

// You can create new method as you needed.
public function newMethod()
{
// function logic
}
}

需要获得 额外 的重写 正则表达式 的确切原因 这将导致 非常 辛苦。 在这一部分

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值