0

I want to override Mage_Sales_Recurring_ProfileController in my custom module.

My /etc/config.xml

<config>
    <frontend>
        <routers>
            <sales>
                <args>
                    <modules>
                        <Namespace_Module before="Mage_Sales">Namespace_Module</Namespace_Module>
                    </modules>
                </args>
            </sales>
        </routers>
    </frontend>
</config>

and my controller file

Namespace/Module/controllers/Sales/Recurring/ProfileController.php


require_once("Mage/Sales/controllers/Recurring/ProfileController.php");
class Namespace_Module_Sales_Recurring_ProfileController extends Mage_Sales_Recurring_ProfileController
{
   public function indexAction()
    {
       // custom code
    }
}

But the control doesnt go in the overriden controller, but the core controller only.

Can anyone tell the reason why.

Amit Bera
  • 77,456
  • 20
  • 123
  • 237
Manashvi Birla
  • 8,833
  • 9
  • 27
  • 53

1 Answers1

1

You can do one (and just one) of the following.

  1. Put your controller in Namespace/Module/controllers/Recurring/ProfileController.php and name the class Namespace_Module_Recurring_ProfileController. (I recommend this one).
  2. Change in config.xml this <Namespace_Module before="Mage_Sales">Namespace_Module</Namespace_Module> to this <Namespace_Module before="Mage_Sales">Namespace_Module_Sales</Namespace_Module>. You should use this only if you override multiple controllers from multiple modules in your module. This helps you group the controllers better. If you only override controllers from Mage_Sales, there is no need to do this. Go with the first approach.
Marius
  • 197,939
  • 53
  • 422
  • 830