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
}
}

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

你可能感兴趣的:(Magento的控制器改写规则)