If you're thinking about customizing Magento admin core functionality or want to change core functionality of any controller. Don't worry, it's very easy. You need to override controller action with your controller action. In this post, I have explained how to override Magento admin controllers.
How to override magento admin controller action
This example show you override edit action from ProductController.php located app/code/core/Mage/Adminhtml/controllers/Catalog
Step 1: Create new module from app/etc/Justwebdevelopment_Overridecontroller.xml
Step 2: Make config.xml from
app/code/local/Justwebdevelopment/Overridecontroller/etc/config.xml
Using above code you can override any action from any adminhtml controller. Only you need to make controller file for that.
Here I want to give example of ProductController.php file.
Step 3: Make controller file from
app/code/local/Justwebdevelopment/Overridecontroller/controllers/Catalog/ProductController.php
And first include your default controller class file then write new controller class for update then extends your new controller file to your default controller class like here extends with “Mage_Adminhtml_Catalog_ProductController”. After the define those action which you want to override.
If you follow these three steps explained above then when you try to edit any products from backend then it shows this message “Override Product Edit Action…”. Please be careful with module name and controller name.
How to override magento admin controller action
This example show you override edit action from ProductController.php located app/code/core/Mage/Adminhtml/controllers/Catalog
Step 1: Create new module from app/etc/Justwebdevelopment_Overridecontroller.xml
<?xml version=“1.0”?>
<config>
<modules>
<Justwebdevelopment_Overridecontroller>
<active>true</active>
<codePool>local</codePool>
</Justwebdevelopment_Overridecontroller>
</modules>
</config>
Step 2: Make config.xml from
app/code/local/Justwebdevelopment/Overridecontroller/etc/config.xml
<?xml version=“1.0”?>
<config>
<modules>
<Justwebdevelopment_Overridecontroller>
<version>0.0.1</version>
</Justwebdevelopment_Overridecontroller>
</modules>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<Justwebdevelopment_Overridecontroller before=“Mage_Adminhtml”>Justwebdevelopment_Overridecontroller</Justwebdevelopment_Overridecontroller>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
Using above code you can override any action from any adminhtml controller. Only you need to make controller file for that.
Here I want to give example of ProductController.php file.
Step 3: Make controller file from
app/code/local/Justwebdevelopment/Overridecontroller/controllers/Catalog/ProductController.php
And first include your default controller class file then write new controller class for update then extends your new controller file to your default controller class like here extends with “Mage_Adminhtml_Catalog_ProductController”. After the define those action which you want to override.
include_once(“Mage/Adminhtml/controllers/Catalog/ProductController.php”);
class Justwebdevelopment_Overridecontroller_Catalog_ProductController extends Mage_Adminhtml_Catalog_ProductController
{
public function editAction(){
echo “Override Product Edit Action…”;exit;
}
}
If you follow these three steps explained above then when you try to edit any products from backend then it shows this message “Override Product Edit Action…”. Please be careful with module name and controller name.