cancel
Showing results for 
Search instead for 
Did you mean: 

Magento Oauth Adminhtml controller class Override

Magento Oauth Adminhtml controller class Override

I want to Override magento core controller class which is present under 'Oauth' module.

Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.php

 

Module declaration xml:

 

<?xml version="1.0" encoding="UTF-8"?>

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

 

My config.xml is :

 

<?xml version="1.0" encoding="UTF-8"?>

<config>
    <modules> 
        <DS_Adminextended> 
            <version>1.0.0</version> 
        </DS_Adminextended> 
    </modules>
                         
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <DS_Adminextended before="Mage_Adminhtml">DS_Adminextended</DS_Adminextended>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
</config> 

i had also use this one but invain:

 

 

<modules>
 <DS_Adminextended before="Mage_Adminhtml">DS_Adminextended_Adminhtml_Oauth</DS_Adminextended>
 </modules>

and extended AuthorizeController.php :

 

 

<?php

require_once("Mage/Oauth/Adminhtml/Oauth/AuthorizeController.php");

die('bla bla bla');

class DS_Adminextended_Adminhtml_Oauth_AuthorizeController extends Mage_Oauth_Adminhtml_Oauth_AuthorizeController {

public function indexAction()
{
echo 'extendedController';exit;
$this->_initForm();
$this->_initLayoutMessages($this->_sessionName);
$this->renderLayout();
}
}

 

But it did not include the extended file.

This 'Adminhtml' present inside the MageSmiley Surprisedauth Folder not in Mage:Adminhtml

So Question is how we can extend admin controller class present under non admin module like:

1) Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.php

OR

2) Mage/Widget/controllers/Adminhtml/Widget/InstanceController.php

 

what i am missing in above code ?

 

 

3 REPLIES 3

Re: Magento Oauth Adminhtml controller class Override

This is not an answer to your question, but did you consider using an observer in stead of overwriting the controller?

 

Also, you should add a line to your module XML file: <depends><Mage_Oauth /></depends> after <codePool>.

 

And to actually answer your question, this line is not correct:

 

<DS_Adminextended before="Mage_Adminhtml">DS_Adminextended</DS_Adminextended>

It should be like this:

 

<DS_Adminextended before="Mage_Adminhtml">DS_Adminextended_Adminhtml</DS_Adminextended>

 

Also, take a look here for more info: http://magento.stackexchange.com/questions/10454/override-a-controller-in-adminhtml.

If this response was helpful to you, consider giving kudos to this post.
If this response solved your problem, click accept as solution to help others solve this

Re: Magento Oauth Adminhtml controller class Override

Arjen Miedema thanks for your reply, Actually Ihave to change the complete functionality of Oauth Rest Api. In my case I am removing the on site user authorization step and sending user/password with Tokan varification request. So thats why I am not using event/observer.

I had successfully override the customer path customer can get the products information this is customers module configuration working perfectly.

<frontend>
        <routers>
            <oauth>
                <args>
                    <modules>
                        <DS_Coreextended before="Mage_Oauth">DS_Coreextended</DS_Coreextended>
                    </modules>
                </args>
            </oauth>
        </routers>
    </frontend>

I use your suggested code:

<DS_Adminextended before="Mage_Adminhtml">DS_Adminextended_Adminhtml</DS_Adminextended>

but having no luck.

still using /var/www/html/magento/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.php this file.

insted     /var/www/html/magento/app/code/local/DS/Adminextended/controllers/Adminhtml/Oauth/AuthorizeController.php

Re: Magento Oauth Adminhtml controller class Override

I find the solution:

<admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <DS_Adminextended before="Mage_Oauth">DS_Adminextended_Adminhtml</DS_Adminextended>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>

This is the correct config file if you want to extend admin module not present in Mage::admin
magic is here: 

<modules><DS_Adminextended before="Mage_Oauth">DS_Adminextended_Adminhtml</DS_Adminextended></modules>

you have to place "Mage_Oauth" in before instead to "Mage_Adminhtml" even if its appearing in adminhtml. secondly 

path to controller call should be "DS_Adminextended_Adminhtml" not even if your base contrroller have one more directory inside like in my case 'DS_Adminextended_Adminhtml_Oauth' .