How to overwrite magento controller action from own module?

356 Views Asked by At

I try to overwrite the function indexAction from "app\code\core\Mage\Newsletter\controllers\ManageController.php" with my own.

I duplicated the controller to app\code\local\Fekete\Newsletter2Go\controllers\ManageController.php and only let the function indexAction there.

<?php

require_once 'Mage/Newsletter/controllers/ManageController.php';

class Fekete_Newsletter2Go_ManageController extends Mage_Newsletter_ManageController
{
    public function indexAction()
    {
        exit("test");
    }
}

Then I added the following code inside the <config></config> tags in: app\code\local\Fekete\Newsletter2Go\etc\config.xml:

<frontend>
    <routers>
        <newsletter>
            <args>
                <modules>
                    <Fekete_Newsletter2Go before="Mage_Newsletter">
                        Fekete_Newsletter2Go
                    </Fekete_Newsletter2Go>
                </modules>
            </args>
        </newsletter>
    </routers>
</frontend>

But If I go to http://example.com/newsletter/manage/ then nothing has changed, my overwrite was not used.

What am I missing?

1

There are 1 best solutions below

0
Black On BEST ANSWER

I found the cause for the problem. I had to change this:

<Fekete_Newsletter2Go before="Mage_Newsletter">
    Fekete_Newsletter2Go
</Fekete_Newsletter2Go>

to this:

<Fekete_Newsletter2Go before="Mage_Newsletter">Fekete_Newsletter2Go</Fekete_Newsletter2Go>