0

I'm trying to extend the core AccountController.php -> app/code/core/Mage/Customer copied it to app/code/local/Mage/ and add a log to see which extends properly.

In the file AccountController.php (app/code/local/Mage/Customer/controllers)
...
...
public function createPostAction() {
        Mage::log('In app/code/local/Mage/', null, 'test.log', true);
...
...

AND CORE (only test)
In the file AccountController.php (app/code/core/Mage/Customer/controllers)
...
...
public function createPostAction() {
        Mage::log('In app/code/core/Mage/', null, 'test.log', true);
...
...

And does not go through code/local/ Mage but by CORE. I need to configure something or it fails?

So I created a separate module following this tutorial: http:// aqpredict.com/blog/overriding-account-contoller-magento/ does not work.

anyone has an example of this, thanks.

2 Answers 2

2

I answered this question of yours over at StackOverflow:

The logic through which controller class definitions are loaded builds the path to the file above the explicit include paths on which the autoloader relies. This means no local vs. core precedence.

You need to creat a controller rewrite by specifying a directory under the xpath frontend/routers/customer/args/modules/your_module

The latter node needs the before attribute set to Mage_Customer and you will need to create an AccountController.php with a createPostAction() method. Depending on your needs you may or may not need to extend from and require the core account controller class.

2
  • sorry did not see the answer on StackOverflow, I've created a new module in the config add a rewrite is that right? You have an example of how it should be or I send the structure of everything and tell me I'm doing wrong.?
    – Alexd2
    Jul 12, 2013 at 12:16
  • My example is in my code. Follow the directions (create xpath, etc.) and it will work fine.
    – benmarks
    Jul 12, 2013 at 14:29
1

In your module etc/config.xml

<frontend>
  <routers>
    <customer>
      <args>
        <modules>
          <your_module before="Mage_Customer">Your_Module_Customer</your_module>
        </modules>
      </args>
    </customer>
  </routers>
</frontend>

Now create your custom AccountController in Your/Module/controllers/Customer/AccountController.php

<?php
require_once 'Mage'.DS.'Customer'.DS.'controllers'.DS.'AccountController.php';
class Your_Module_Customer_AccountController extends Mage_Customer_AccountController {
    // Here you can override your methods
}

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.