0

Most of today I have been trying to override Mage controller and I have no ideas what I'm doing wrong. Does anyone can help me.

app/code/local/Fox/Extacl/etc/config.xml

<modules>
    <Fox_Extacl>
        <version>0.1.0</version>
    </Fox_Extacl>
</modules>
<global>
    <models>
        <admin>
            <rewrite>
                <session>Fox_Extacl_Model_Session</session>
            </rewrite>
        </admin>
    </models>
    <blocks>
        <adminhtml>
            <rewrite>
                <permissions_user_edit_tab_roles>Fox_Extacl_Block_Permissions</permissions_user_edit_tab_roles>
            </rewrite>
        </adminhtml>
    </blocks>
</global>
<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <Fox_extacl before="Mage_Adminhtml">Fox_Extacl_Adminhtml</Fox_extacl>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>

app/code/local/Fox/Extacl/controllers/Adminhtml/UserController.php

<?php 
require_once('/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php');
class Fox_Extacl_Adminhtml_UserController extends Mage_Adminhtml_Controller_Action
{

public function saveAction()
{
    if ($data = $this->getRequest()->getPost()) {
        echo '<pre>';
        print_r($data);

    }
    // $this->_redirect('*/*/');
}
}

Thank you in advance.

0

First change this from config.xml

<Fox_extacl before="Mage_Adminhtml">Fox_Extacl_Adminhtml</Fox_extacl>

to

<Fox_Extacl before="Mage_Adminhtml">Fox_Extacl_Adminhtml</Fox_Extacl>

Now here is how the controller rewrite work.
You requested admin/permissions_user/something.
Magento looks in all the folders mapped to the adminhtml router for this file Permissions/UserController.php.
So in your case, you need to place the file in app/code/local/Fox/Extacl/controllers/Adminhtml/Permissions/UserController.php. You are missing the Permissions folder.
And since you are extending a controller and not replacing it, you should make your class extend the original controller.

require_once '/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php';
class Fox_Extacl_Adminhtml_Permissions_UserController 
    extends Mage_Adminhtml_Permissions_UserController 
{...}
1
  • It did worked! Thank you very much! Maybe wort of mentioning I have also change the require_once path to: require_once '/var/www/html/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php';
    – Foxmark
    Oct 20 '14 at 13:36
1

Since your trying to put your module before Adminhtml

Try

require_once('/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php');
class Fox_Extacl_Adminhtml_Permissions_UserController extends Mage_Adminhtml_Permissions_UserController
{
0

You need to rename your Controller to UserController.

This controller should listen to the route:

/<whateverYourAdminDirIs>/extacl/

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.