0

I am trying to override customer address controller but its't overrides

Config.xml

<frontend>
    <routers>
        <salesperson>
            <use>standard</use>
            <args>
                <module>VestricsB2B_Salesperson</module>
                <frontName>salesperson</frontName>
            </args>
            <!--<args>
                <modules>
                    <general before="Mage_Customer">VestricsB2B_Salesperson</general>
                </modules>
            </args>-->
        </salesperson>

        <customer>
            <args>
                <modules>
                    <general before="Mage_Customer">VestricsB2B_Salesperson</general>
                </modules>
            </args>
        </customer>
    </routers>

    <layout>
        <updates>
            <salesperson>
                <file>salesperson.xml</file>
            </salesperson>
        </updates>
    </layout>
</frontend>

AccountController.php

 require_once(Mage::getModuleDir('controllers','Mage_Customer').DS.'AddressController.php');
class VestricsB2B_Salesperson_AddressController extends Mage_Customer_AddressController {

    public function createPostAction(){
        echo "override"; exit;
    }
}
3
  • Are you sure you want to override AddressController.php? Well, there is no action in Magento core file AddressController.php with name createPostAction. You can try formPostAction Commented Mar 7, 2017 at 7:05
  • @JaiminSutariya , i changed to formPostAction but still not working. can you please confirm router configuration in my confi.xml script
    – Ramesh
    Commented Mar 7, 2017 at 7:11
  • Update <general before="Mage_Customer">VestricsB2B_Salesperson</general> to <VestricsB2B_Salesperson before="Mage_Customer">VestricsB2B_Salesperson</VestricsB2B_Salesperson>. Try updating your file name from AccountController.php to AddressController.php Commented Mar 7, 2017 at 7:21

1 Answer 1

0

Instead, you can try as:

...   
 <frontend>
        <routers>
            <customer>
                <args>
                    <modules>
                        <company_modulename before="Mage_Customer">Company_Modulename</company_modulename>
                    </modules>
                </args>
            </customer>
        </routers>
    </frontend>
...

And create a controller class: app/code/[codePool]/Company/Modulename/controllers/AccountController.php with the following code:

require_once 'Mage/Customer/controllers/AccountController.php';
class Company_Modulename_AccountController extends Mage_Customer_AccountController
{
    public function createPostAction(){
        die('Overriden');
    } 
}

Thank you.

1
  • i have another router in same config.xml can i add another router tag
    – Ramesh
    Commented Mar 7, 2017 at 7:06

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.