Override admin controller in Magento

override admin in controller in magento

Step 1

Create a new module under your local folder, in our case under applocalScommerceCatalog. Now create config.xml with the following -:

<?xml version="1.0" encoding="UTF-8"?>
<config> <modules> <Scommerce_HelloWorld> <version>0.0.1</version> </Scommerce_Catalog> </modules> <admin> <routers> <adminhtml><!--This should be same as defined in Mage_Adminhtml config.xml--> <args> <modules> <Scommerce_HelloWorld before="Mage_Adminhtml"> Scommerce_HelloWorld </Scommerce_HelloWorld> </modules> </args> </adminhtml> </routers> </admin>
</config>

N.B. – Your controller front name should be same as Mage_Adminhtml

Step 2

Create controller Class under localScommerceHelloWorldcontrollersCatalogProductController.php

<?php require_once Mage::getModuleDir('controllers', 'Mage_Adminhtml').DS.'Catalog'.DS.'ProductController.php'; class Scommerce_HelloWorld_Catalog_ProductController extends Mage_Adminhtml_Catalog_ProductController
{ public function editAction() { //your code will go here }
}

Step 3

This is the most important step of all!

Create your module file in etcmodulesScommerce_HelloWorld.xml

 <Scommerce_HelloWorld> <active>true</active> <codePool>local</codePool>
</Scommerce_HelloWorld> 

That’s it, it is as simple as that. Hope this article helped you in some way. Please leave us your comment and let us know what do you think? Thanks.

Discover more from WHO WILL CARE eCommerce

Subscribe now to keep reading and get access to the full archive.

Continue reading