Magento 1.8 – How to Call Custom Action on Custom Button Click

blockscontrollersmagento-1.8overrides

I have created override file app/code/local/Mage/ImportExport/Block/Adminhtml/Import/Edit.php

and added a button

 $this->_addButton('downloadCsv', array(
            'label' => $this->__('Download CSV'),
            'onclick' => "setLocation('{$this->getUrl('/import/downloadcsv')}')",
        ));

in __construct()

it is work fine if add action function to core controller
app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php

But i want to override controller. so i have created

app/code/local/Mage/ImportExport/controllers/Adminhtml/ImportController.php

and create

public function downloadcsvAction()
{
        // code 
}

but it is not called.

Best Answer

Hi Sandeep,

Ideally, we should not override the controller with the same Namespace 'Mage'.
Just to check, have you followed all the steps for magento controller overriding. 
In your case : Namespace = 'Mage' 
Modulename = 'Importexport'

Please confirm the below things :
1.) in the config.xml of your app/code/local/mage/importexport/etc/config.xml, <config>      <admin>         <routers>             <adminhtml>                 <args>                     <modules>                         <namespace_modulename before="Mage_Adminhtml">Namespace_Modulename_Adminhtml</namespace_modulename>                     </modules>                 </args>             </adminhtml>         </routers>     </admin> </config>
2.) In the file :
app/code/local/Mage/ImportExport/controllers/Adminhtml/ImportController.php Have you include the Core controller class like below : I hope my reply is helpful.