| 将演示如何在不弄乱核心文件本身的前提下编辑Magento核心模块。我选择Magento Customer模块下的Account控制器作为本文的示例。你要先找出它在Magento核心文件夹里的路径(完整路径是:app/code/core/Mage/Customer/controllers/AccountController.php)。 首先创建有类似文件结构的文件: app/code/local/Alwayly/Coreextended/controllers/Frontend/Customer/AccountController.php。(当然,你可以把Alwayly替换成你想要的命名空间,Coreextended换成其它模块名,但你需要对其它部分做相应的修改)。 接着创建我们模块的xml文件:app/code/local/Alwayly/Coreextended/etc/config.xml。将下面的代码写入对应的文件中: 1.AccountController.php:
< ?php
require_once Mage::getModuleDir('controllers', 'Mage_Customer').DS.'AccountController.php';
//we need to add this one since Magento wont recognize it automatically
class Alwayly_Coreextended_Frontend_Customer_AccountController extends 
{//here, you extended the core controller with our public function indexAction()
{
parent::indexAction();
//you can always use default functionality
}
public function myactionAction()
{
//my code
//you can write your own methods / actions
}
public function mymethod()
{
//my code
//you can write your own methods
}
public function loginAction()
{
//finally you can write your code that will rewrite the whole core method
//and you can call for your own methods, as you have full control over core controller
}
}
2.config.xml:
<?xml version="1.0"?>
<config>
    <modules>
        <alwayly_coreextended>
            <version>0.2.0</version>
        </alwayly_coreextended>
    </modules>
    <frontend>
        <routers>
            <customer>
                <args>
                    <modules>
                        <alwayly_coreextended before="Mage_Customer_AccountController">
                               Alwayly_Coreextended_Frontend_Customer
                        </alwayly_coreextended>
                    </modules>
                </args>
            </customer>
        </routers>
    </frontend>
</config>
3.Alwayly_Coreextended.xml:
< ?xml version="1.0"?>
<!--we need to enable this module as any other if-->
<!--you wish to do it as standalone module extension-->
<config>
    <modules>
        <alwayly_coreextended>
            <active>true</active>
            <codepool>local</codepool>
        </alwayly_coreextended>
    </modules>
</config>(责任编辑:最模板) | 



 ecshop家具模板|家具商城程
							人气:418
							ecshop家具模板|家具商城程
							人气:418
						 zencart英文包包通用模板
							人气:1872
							zencart英文包包通用模板
							人气:1872
						 Milano跨境电商综合商城m
							人气:171
							Milano跨境电商综合商城m
							人气:171
						 酒美网模板之shopex免费模
							人气:3505
							酒美网模板之shopex免费模
							人气:3505
						 ecshop英文鞋子模板
							人气:723
							ecshop英文鞋子模板
							人气:723
						 ecshop仿寺库中国奢侈品网
							人气:923
							ecshop仿寺库中国奢侈品网
							人气:923