1

How do you remove the newsletter link from the customer account navigation in Magento?

We have started using the Advanced Newsletter extension and now have two newsletter links in our customer account navigation, one for the the default newsletter and the other for the default newsletter.

I can see that the default newsletter link is added to customer account nav in app/design/frontend/base/default/layout/newsletter.xml on ln 48 with:

<customer_account>
    <!-- Mage_Newsletter -->
    <reference name="customer_account_navigation">
        <action method="addLink" translate="label" module="newsletter"><name>newsletter</name><path>newsletter/manage/</path><label>Newsletter Subscriptions</label></action>
    </reference>
    <remove name="left.newsletter"/>
</customer_account>

I've tried removing this link in our theme's local.xml with:

<reference name="customer_account_navigation">
    <!--<action method="removeLinkByName"><name>newsletter</name></action>-->
    <!--<remove name="newsletter"/>-->
    <action method="removeLinkByUrl"><url helper="newsletter/manage/"/></action>
</reference>

None of these methods have worked for me & I get an error when I try to remove them with an action method.

<action method="removeLinkByName"><name>newsletter</name></action> gives this error: Invalid method Mage_Customer_Block_Account_Navigation::removeLinkByName(Array

<action method="removeLinkByUrl"><url helper="newsletter/manage/"/></action> gives this error: Fatal error: Class 'Mage_Newsletter_Helper_Manage' not found in /app/Mage.php on line 546

While <remove name="newsletter"/> gives no error but does not remove the link

5
  • your removeLinkByName was not working because you dont have the function removeLinkByName in your Mage_Customer_Block_Account_Navigation Block Sep 19, 2014 at 11:34
  • check my answer... Sep 19, 2014 at 11:35
  • @PradeepSanku thanks, isn't it unusual for Magento not to allow you to have a method for removing links inMage_Customer_Block_Account_Navigation Block
    – Holly
    Sep 19, 2014 at 11:36
  • unfortunatly their is no method for removing.so even i got this answer after making some research. Sep 19, 2014 at 11:38
  • Try with <action method="removeLinkByUrl"><url>newsletter/manage</url></action>
    – Marius
    Sep 19, 2014 at 11:48

2 Answers 2

1

You need to rewrite Magento's Customer Mage_Customer_Block_Account_Navigation Block class.

create config.xml file in the app/code/local/Neo/CustomerNavigationLinks/etc

<?xml version="1.0"?>
<config>
    <modules>
        <Neo_CustomerNavigationLinks>
            <version>0.0.1</version>
        </Neo_CustomerNavigationLinks>
    </modules>
    <global>
        <blocks>
            <customer>
                <rewrite>
                    <account_navigation>Neo_CustomerNavigationLinks_Block_Account_Navigation</account_navigation>
                </rewrite>
            </customer>
        </blocks>
        <helpers>
            <customernavigationlinks>
                <class>Neo_CustomerNavigationLinks_Helper</class>
            </customernavigationlinks>
        </helpers>
    </global>
</config>

in Neo/CustomerNavigationLinks/Block/Account/ careate a file called Navigation.php with the following content in it

<?php

class Neo_CustomerNavigationLinks_Block_Account_Navigation extends Mage_Customer_Block_Account_Navigation
{
    public function removeLinkByName($name)
    {
        unset($this->_links[$name]);
        return $this;
    }
}
?>

in app/etc/modules create a file called Neo_CustomerNavigationLinks.xml with the following content

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

Now in local.xml add following content

<customer_account>
        <reference name="customer_account_navigation">
            <action method="removeLinkByName">
                <name>newsletter</name> 
            </action>
        </reference>
</customer_account>
5
  • Does <blocks><customer><rewrite><account_navigation> go in Yourpacakgename/CustomerNavigationLinks/etc/config.xml ?
    – Holly
    Sep 19, 2014 at 11:39
  • yes right......... Sep 19, 2014 at 11:40
  • check my updated answer Sep 19, 2014 at 11:44
  • is my solutoin worked for you ? Sep 19, 2014 at 12:12
  • But what if the name is missing ? from the xml ? Nov 24, 2015 at 9:10
0

In addition to Pradeep's clever solution above, I also found a good extension for allowing you to manage these links from the Magento Admin Panel

https://github.com/integer-net/RemoveCustomerAccountLinks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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