7

Currently I'm trying to override the GroupController of Mage_Adminhtml_Customer so I can add some code for saving my custom field in the Customer Groups menu. As you can think it doesn't really work as I want what means that it seems that my controller is ignored by Magento so far but I don't get the mistake I've made. Here are the snippets:

<?xml version="1.0" ?>
<config>
    [...]
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <Mynamespace_CustomerGroupReturnable before="Mage_Adminhtml">Mynamespace_CustomerGroupReturnable</Mynamespace_CustomerGroupReturnable>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
</config>

And the controller:

require_once 'Mage/Adminhtml/Customer/controllers/GroupController.php';

class Mynamespace_CustomerGroupReturnable_GroupController extends Mage_Adminhtml_Customer_GroupController
{
    public function saveAction()
    {
        die(':D'); //just for testing
    }
}

Can anybody see what's missing? Thanks!

  • 1
    I think you are requiring the wrong file. This Mage/Adminhtml/Customer/controllers/GroupController.php should be Mage/Adminhtml/controllers/Customer/GroupController.php – Marius Nov 6 '13 at 11:38
  • Oh, yep, you're right. Thank you! However Magento is still not amazed and ignores it. – HamuSumo Nov 6 '13 at 12:38
14

Put your controller file under an Admintml folder. Better to use a similar folder path of the class which you are going to override.

config.xml

<?xml version="1.0" ?>
<config>
    [...]
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <Mynamespace_CustomerGroupReturnable before="Mage_Adminhtml">Mynamespace_CustomerGroupReturnable_Adminhtml</Mynamespace_CustomerGroupReturnable>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
</config>

Controller file :

require_once 'Mage/Adminhtml/controllers/Customer/GroupController.php';

class Mynamespace_CustomerGroupReturnable_Adminhtml_GroupController extends Mage_Adminhtml_Customer_GroupController
{
    public function saveAction()
    {
        die(':D'); //just for testing
    }
}
|improve this answer|||||
  • Yep, the missing Adminhtml folder was causing the trouble. Thanks! – HamuSumo Nov 11 '13 at 11:29
  • 2
    And also so (IMPORTANT for this method) that the path to the controller under the Adminhtml sould match the path of the overloaded controller. for instance: Mage/Adminhtml/controllers/Catalog/productController.php My_Module/controllers/Adminhtml/Catalog/productController.php – Mohamed23gharbi Dec 30 '14 at 21:14
0

Ok start testing.

First add a die before the class definition to check whether the class file is loaded.

Then add a space in <conf ig> to check whether your config file is loaded.

Check the backend System > Config > Advanced whether you can prevent the output of your module (if yes, the module.xml in app/etc/modules is at least loaded)

What url do you test? should be:

http://magento.local//group/save

Disable the auth key in the backend (don'T ask me where) to prevent an error with the missing auth key in the url

And the last words: Code looks good, I think the mistake is somewhere else.

|improve this answer|||||

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.