0

I realise, there are several Questions that are basically the same - with solutions. Sadly, I still can't figure out what is wrong.

Problem: I'd like to extend the Mage_Newsletter_SubscriberControllerto add some custom code. The new Controller, which extends said controller, is never called.

We use Magento 1.9.2.1 with some manual security patches.

Here is what I've done, so far:

Registered a new Module in app/etc/modules/MM_Newsletter.xml

    <?xml version="1.0" ?>
    <config>
        <modules>
            <MM_Newsletter>
                <active>true</active>
                <codePool>local</codePool>
            </MM_Newsletter>
        </modules>
    </config>

Set how it should override the controller in app/code/local/MM/Newsletter/etc/config.xml

<?xml version="1.0" encoding="utf-8"?>
<config>
    <modules>
        <MM_Newsletter>
            <version>0.1.0</version>
        </MM_Newsletter>
    </modules>

    <frontend>
        <routers>
            <newsletter>
                <!--<subscriber>-->
                    <!--<new>-->
                        <args>
                            <modules>
                                <MM_Newsletter before="Mage_Newsletter">MM_Newsletter</MM_Newsletter>
                            </modules>
                        </args>
                    <!--</new>-->
                <!--</subscriber>-->
            </newsletter>
        </routers>
    </frontend>
</config>

With the commented nodes I tried to reflect the actual route that is called from the frontend. Either way, it doesn't work.

Extended the Controller in app/code/local/MM/Newsletter/controllers/MM_Newsletter_SubscriberController.php

<?php

require_once Mage::getModuleDir('controllers', 'Mage_Newsletter').DS.'SubscriberController.php';

class MM_Newsletter_SubscriberController extends Mage_Newsletter_SubscriberController{

    public function newAction()
    {
       // some custom code ...

        parent::newAction();
    }
}

The custom code is never executed. The caches are always emptied, when I push changes to the server. They are guaranteed to be empty, even though I checked manually, too. XDebug is set up and breakpoints in the custom controller are never hit. When i let it die(), to see if just the debugger doesn't register correctly, it also just calls the original controller and does not perform the custom code.

Is there something missing? FYI: I also tried the older rewrite syntax in the xml config, which didn't work either.

Any help is greatly appreciated!

2

Your controller location should be

app/code/local/MM/Newsletter/controllers/SubscriberController.php

Content:


require_once Mage::getModuleDir('controllers', 'Mage_Newsletter').DS.'SubscriberController.php';

class MM_Newsletter_SubscriberController extends Mage_Newsletter_SubscriberController
{
    public function newAction()
    {
        // some custom code ...
        parent::newAction();
    }
}

Also clean your app/code/local/MM/Newsletter/etc/config.xml


<?xml version="1.0" encoding="utf-8"?>
<config>
    <modules>
        <MM_Newsletter>
            <version>0.1.0</version>
        </MM_Newsletter>
    </modules>
    <frontend>
        <routers>
            <newsletter>
                <args>
                    <modules>
                        <MM_Newsletter before="Mage_Newsletter">MM_Newsletter</MM_Newsletter>
                    </modules>
                </args>
            </newsletter>
        </routers>
    </frontend>
</config>

Clear cache.

  • Many thanks, It had to be something basic. The comments in the config was just to illustrate another attempt and have been removed, since. Thank you, again! – devastato May 23 '17 at 11:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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