In Magento, suppose we wanted to override/rewrite the core adminhtml controller class which is originally based in app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php

To override a core adminhtml controller, we need to do the following,

1. Create a new module named “AU_OverrideCatalogProduct”.

2. Create the global module config file in app/etc/modules/AU_OverrideCatalogProduct.xml with following content:

<?xml version="1.0"?>
<config>
    <modules>
        <AU_OverrideCatalogProduct>
            <active>true</active>
            <codePool>local</codePool>
        </AU_OverrideCatalogProduct>
    </modules>
</config>

3. Create the module in “local” code-pool. The illustration would be as follows:

app/code/local/AU/OverrideCatalogProduct/etc/config.xml

app/code/local/AU/OverrideCatalogProduct/controllers/Catalog/ProductController.php

4. In module config file, which is app/code/local/AU/OverrideCatalogProduct/etc/config.xml, add the following content

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <AU_OverrideCatalogProduct>
            <version>0.0.1</version>
        </AU_OverrideCatalogProduct>
    </modules>

    <!--Overriding adminhtml Catalog/ProductController -->
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <au_overridecatalogproduct before="Mage_Adminhtml">AU_OverrideCatalogProduct</au_overridecatalogproduct>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>

</config>

5. Ensure that we manually load the controller using require_once method and our newly created

AU/OverrideCatalogProduct/controllers/Catalog/ProductController.php

extends from Mage_Adminhtml_Catalog_ProductController like below:

//need to manually load the adminhtml controllers
require_once 'Mage/Adminhtml/controllers/Catalog/ProductController.php';

class AU_OverrideCatalogProduct_Catalog_ProductController extends Mage_Adminhtml_Catalog_ProductController { 

}

That’s all. If we do have cache enabled, to see the effect clear the cache and should be fine.