Magento – Use getUrl() in form action in Magento1.9

customer-addressgeturlmagento-1.9

I Want to add some new functionality for magento address book page, I create a Form their, and want to add an action via function like Add New Address Form.

Step1. : I Create a new function in
app/code/local/Mage/Customer/Block/Address/Edit.php

public function **getImpAddrURL**()
{
    return Mage::getUrl('customer/address/**importAddr**');
}

Step2. : Create a New function in Controller app/code/local/Mage/Customer/controllers/AddressController.php

public function importAddrAction()
{
    echo "Hello"; exit;
}

Step3. : Create a form in Address Book : frontend/theme/mytheme/template/customer/address/book.phtml

<form action="echo $this->getImpAddrURL() ?>">
My Other fields here
</form>

But When I click on submit button I have an URL Like :

http://*******/****/index.php/customer/address/importAddresses/

And 404 Error.

Please Suggest how can I use this.

Best Answer

You can not copy any controller file in local folder. Instead of copy customer controller you can create same method

public function importAddrAction() { echo "Hello"; exit; }

in any of your custom controller. and return that controller url fron getUrl method.