0

I need to modify on Mage module newsletter to add new action for amp requirement but adding new function amp showing 404 result .

1
  • Please share your code.
    – PЯINCƎ
    Jan 15, 2018 at 13:45

1 Answer 1

3

First of all, you should never edit the Mage module directly If you do and in future, and you upgrade Magento version then you will lose your changes. To avoid this in Magento you can override the core class into your module. To do this you just need to create a new simple module.

So first create a Test_Newsletter.xml in app/etc/modules/Test_Newsletter.xml directory.

Now in this file you need to write below code

<?xml version="1.0"?>
<config>
    <modules>
        <Test_Newsletter>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Newsletter/>
            </depends>
        </Test_Newsletter>
    </modules>
</config>

Now you need to create a config.xml in app/code/local/Test/Newsletter/etc/config.xml this file conains configuration of your module. In this file you need to write

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

Now create a SubscriberController.php in app/code/local/Test/Newsletter/controllers/SubscriberController.php This file overwrites the newsletter controller so you can add your custom method here or update existing methods. In this file, you need to write

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

class Test_Newsletter_SubscriberController extends Mage_Newsletter_SubscriberController
{
    public function newAction()
    {
    }
}

In Test_Newsletter Test is my company name Newsletter is module name you can update it as per your requirement. and last but not the least clear your webshop cache.

0

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.