Magento的helper重写规则

本文详细介绍了如何在Magento中覆盖辅助类Mage_Customer_Helper_Data,包括创建模块、配置XML文件及重写方法的具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

有时 Magento用于 辅助类 来检索 帮助信息 网址, 名称,组 等,所以 必须要覆盖 辅助类 当你 想改变任何 网址或 一些 别的东西 辅助类 覆盖 类似于 块和 模型 覆盖。 在这里, 用实例 说明 有关 辅助 覆盖 的细节。 在这里, 我将展示 如何覆盖 辅助类 Mage_Customer_Helper_Data


1.首先创建 新的模块 处理 下面的代码 重写 工作,并 写在 app/etc/modules/Yt_Customer.xml

<?xml version="1.0"?>
<config>
<modules>

<Yt_Customer>

<active>true</active>

<codePool>local</codePool>

</Yt_Customer>

</modules>

</config>
2。 做好 app/code/local/Yt/Customer/etc/config.xml 配置


<?xml version="1.0"?>


<config>


<modules>


<Yt_Customer>


<version>0.1.0</version>


</Yt_Customer>


</modules>





<global>


<helpers>


<customer>


<rewrite>


<data>Yt_Customer_Model_Customer</data>


</rewrite>


</customer>


</helpers>


</global>


</config>

3。
现在, 你的新helper Yt_Customer_Helper_Data 定义所有其他 覆盖方法


class Yt_Customer_Helper_Data extends Mage_Customer_Helper_Data
{
// override existing method

* Retrieve customer register form post url
public function getRegisterPostUrl()
{
return $this->_getUrl('customer/account/create2')
}

//write new function
public function getRegisterPostUrl2()

{

return $this->_getUrl('customer/account/createpost');
}


}
我觉得 谁是 熟悉的 理论 与Magento 覆盖 覆盖 帮助 他们 容易




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值