Magento – How to extend magento Admin customer Contoller, Block and Helper

adminhtmlcustommagento-enterpriseoverrides

In the Magento admin, I would like to do some changes in the following files.

  • app\code\core\Mage\Adminhtml\Block\Customer\Grid.php
  • app\code\core\Mage\Adminhtml\controllers\CustomerController.php
  • app\code\core\Mage\Adminhtml\Helper\Data.php

How can I extend these changes and implement without touching the core files. I have searched in google but i couldn't find the solutions.

Awaiting for valuable reply

Best Answer

Follow below steps, create one custom module

app/code/local/Custom/Module/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Custom_Module>
            <version>0.1.0</version>
        </Custom_Module>
    </modules>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <Custom_Module before="Mage_Adminhtml">Custom_Module</Custom_Module>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
    <global>
        <helpers>
            <module>
                <class>Custom_Module_Helper</class>
            </module>
            <adminhtml>
                <rewrite>
                    <data>Custom_Module_Helper_Adminhtml_Data</data>
                </rewrite>
            </adminhtml>
        </helpers>
        <blocks>
            <module>
                <class>Custom_Module_Block</class>
            </module>
            <adminhtml>
                <rewrite>
                    <customer_grid>Custom_Module_Block_Adminhtml_Customer_Grid</customer_grid>
                </rewrite>
            </adminhtml>
        </blocks>
    </global>
</config> 

app/code/local/Custom/Module/Block/Adminhtml/Customer/Grid.php

<?php

class Custom_Module_Block_Adminhtml_Customer_Grid extends Mage_Adminhtml_Block_Customer_Grid {

}

app/code/local/Custom/Module/Helper/Adminhtml/Data.php

<?php

class Custom_Module_Helper_Adminhtml_Data extends Mage_Adminhtml_Helper_Data {

}

app/code/local/Custom/controllers/CustomerController.php

<?php
include_once("Mage/Adminhtml/controllers/CustomerController.php");
class Custom_Module_CustomerController extends Mage_Adminhtml_CustomerController
{
}
?>

And finally declare your module

app/etc/modules/Custom_Module.xml

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