0
votes

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 Mage/Oauth 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 ?

2

2 Answers

0
votes

You've made a mistake in the require_once path and missed the controllers directory. Try

require_once 'Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.php';
0
votes

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 as per core directory 'DS_Adminextended_Adminhtml_Oauth' .

Hope this will help someone and save time, please rank up if it help you :-)