0

click

System > My Account

When I click on 'save account' button,it will call saveAction() method,saveAction() location is "Mage/Adminhtml/controllers/System/AccountController.php",I tried to override saveAction() method but i can't, I also delete cache but it doesn't override system accountcontroller,please check my code where is my mistake ?

app/code/local/Test/Module/etc/config.xml

<config>
    <modules>  
       <Test_Module>  
         <version>0.0.1</version>  
       </Test_Module>  
     </modules>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <Test_Module before="Mage_Adminhtml">Test_Module_Adminhtml</Test_Module>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin> 
</config>

app/code/local/Test/Module/controllers/Adminhtml/AccountController.php

     <?php
  //require_once 'Mage/Adminhtml/controllers/System/AccountController.php'; 
 require_once(Mage::getModuleDir('controllers','Mage_Adminhtml_System').DS.'AccountController.php');

    class Test_Module_Adminhtml_AccountController extends Mage_Adminhtml_System_AccountController
    {
        public function saveAction() 
        {
            die('override');
        }
    }
    ?>

app/etc/modules/Test_Module.xml

<config>
    <modules>
        <Test_Module>
            <active>true</active>
            <codePool>local</codePool>
        </Test_Module>
    </modules>
</config>

1 Answer 1

3

Try this:

Your app/code/local/Test/Module/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>  
       <Test_Module>  
         <version>0.0.1</version>  
       </Test_Module>  
     </modules>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <test_module before="Mage_Adminhtml">Test_Module_Adminhtml</test_module>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin> 
</config>

Your app/code/local/Test/Module/controllers/Adminhtml/System/AccountController.php

<?php
//require_once 'Mage/Adminhtml/controllers/System/AccountController.php';

require_once(Mage::getModuleDir('controllers','Mage_Adminhtml').DS.'System'.DS.'AccountController.php');

class Test_Module_Adminhtml_System_AccountController extends Mage_Adminhtml_System_AccountController
{
    public function saveAction() 
    {
        die('override');
    }
}
?>

Remember

Folder structure should be exactly as core controller is.

15
  • I used your code but Still not working Sep 21, 2015 at 10:22
  • I have updated my answer, I think there was problem in config.xml too. Sep 21, 2015 at 10:25
  • If still doesn't work, I doubt it's naming problem for your NameSpace and ModuleName. You might want to change Package1 and Module1 to something different, without number. Sep 21, 2015 at 10:27
  • Still not working,also delete cache folder but why it doesn't work ? Sep 21, 2015 at 10:29
  • ok I am updating Sep 21, 2015 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.