1

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.

2 Answers 2

1
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.
1

You can use below code to override controller.
Code in config.xml

 <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <custom_extension before="Mage_ImportExport">Custom_Extension_Adminhtml</custom_extension>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>

Code in your custom controller file

 require_once 'Mage'.DS.'ImportExport'.DS.'controllers'.DS. 'Adminhtml'.DS.'ImportController.php';
class Custom_Extension_Adminhtml_ImportController extends Mage_ImportExport_Adminhtml_ImportController
{//Your custom or overrided methods}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.