Quantcast
Channel: Peter Jaap's Blog
Viewing all articles
Browse latest Browse all 12

Easily remove My Account dashboard links

$
0
0

There is no easy & quick way to delete the dashboard links, like “Downloadable Products”, “Recurring Profiles”, “My Tags”, “My Reviews” etcetera. The solutions offered involved a lot of manual work, such as adding a removeLinkByName or removeLinkByUrl action method and editing the local.xml file, or copying all relevant XML files and commenting out the addLink portion. Since this is a recurring task for every Magento installation, I decided to make a small bash script to help me out with this.

It works by saving the code below to a file (name it “removeLinks” for example) and making it executable (“chmod +x removeLinks”). Then run it by typing “./removeLinks”. You can add parameters like themename and packagename, in this order; “./removelinks themename packagename”. It defaults to default/default if you don’t give any arguments.

Enjoy, and remember; don’t hack core!

#! /bin/bash
# Remove dashboard links, by Elgentos <www.elgentos.nl / @elgentos / @peterjaap>

if [[ -z "$1" ]]; then
		THEMEDIR="default"
else
		THEMEDIR="$1"
fi

if [[ -z "$2" ]]; then
		PACKAGEDIR="default"
else
		PACKAGEDIR="$2"
fi

BASE="app/design/frontend/base/default/layout/"
THEME="app/design/frontend/${PACKAGEDIR}/${THEMEDIR}/layout/"

read -p "Remove Billing Agreements link? (y/n)" yn
FILENAME="sales/billing_agreement.xml"
FULLPATH="${THEME}${FILENAME}"

case $yn in
	[YyJj]* )           if [ -e ${FULLPATH} ]; then
						echo "File already exists; make modifications in existing file"
						else
						echo "File doesn't exist; copy first"
						mkdir -p `dirname ${FULLPATH}`
						cp ${BASE}${FILENAME} ${FULLPATH}
						fi
						sed -i 's/<action method="addLink" translate="label"><name>billing_agreements<\/name><path>sales\/billing_agreement\/<\/path><label>Billing Agreements<\/label><\/action>/<!--action method="addLink" translate="label"><name>billing_agreements<\/name><path>sales\/billing_agreement\/<\/path><label>Billing Agreements<\/label><\/action-->/' ${FULLPATH}
						echo "Link removed"
esac

read -p "Remove Recurring Profiles link? (y/n)" yn
FILENAME="sales/recurring_profile.xml"
FULLPATH="${THEME}${FILENAME}"
case $yn in
	[YyJj]* )           if [ -e ${FULLPATH} ]; then
						echo "File already exists; make modifications in existing file"
						else
						echo "File doesn't exist; copy first"
						mkdir -p `dirname ${FULLPATH}`
						cp ${BASE}${FILENAME} ${FULLPATH}
						fi
						sed -i 's/<action method="addLink" translate="label"><name>recurring_profiles<\/name><path>sales\/recurring_profile\/<\/path><label>Recurring Profiles<\/label><\/action>/<!--action method="addLink" translate="label"><name>recurring_profiles<\/name><path>sales\/recurring_profile\/<\/path><label>Recurring Profiles<\/label><\/action-->/' ${FULLPATH}
						echo "Link removed"
esac

read -p "Remove Product Reviews link? (y/n)" yn
FILENAME="review.xml"
FULLPATH="${THEME}${FILENAME}"
case $yn in
	[YyJj]* )           if [ -e ${FULLPATH} ]; then
						echo "File already exists; make modifications in existing file"
						else
						echo "File doesn't exist; copy first"
						mkdir -p `dirname ${FULLPATH}`
						cp ${BASE}${FILENAME} ${FULLPATH}
						fi
						sed -i 's/<action method="addLink" translate="label" module="review"><name>reviews<\/name><path>review\/customer<\/path><label>My Product Reviews<\/label><\/action>/<!--action method="addLink" translate="label" module="review"><name>reviews<\/name><path>review\/customer<\/path><label>My Product Reviews<\/label><\/action-->/' ${FULLPATH}
						echo "Link removed"
esac

read -p "Remove My Tags link? (y/n)" yn
FILENAME="tag.xml"
FULLPATH="${THEME}${FILENAME}"
case $yn in
	[YyJj]* )           if [ -e ${FULLPATH} ]; then
						echo "File already exists; make modifications in existing file"
						else
						echo "File doesn't exist; copy first"
						mkdir -p `dirname ${FULLPATH}`
						cp ${BASE}${FILENAME} ${FULLPATH}
						fi
						sed -i 's/<action method="addLink" translate="label" module="tag"><name>tags<\/name><path>tag\/customer\/<\/path><label>My Tags<\/label><\/action>/<!--action method="addLink" translate="label" module="tag"><name>tags<\/name><path>tag\/customer\/<\/path><label>My Tags<\/label><\/action-->/' ${FULLPATH}
						echo "Link removed"
esac

read -p "Remove My Wishlist link? (y/n)" yn
FILENAME="wishlist.xml"
FULLPATH="${THEME}${FILENAME}"
case $yn in
	[YyJj]* )           if [ -e ${FULLPATH} ]; then
						echo "File already exists; make modifications in existing file"
						else
						echo "File doesn't exist; copy first"
						mkdir -p `dirname ${FULLPATH}`
						cp ${BASE}${FILENAME} ${FULLPATH}
						fi
						sed -i 's/<action method="addLink" translate="label" module="wishlist" ifconfig="wishlist\/general\/active"><name>wishlist<\/name><path>wishlist\/<\/path><label>My Wishlist<\/label><\/action>/<!--action method="addLink" translate="label" module="wishlist" ifconfig="wishlist\/general\/active"><name>wishlist<\/name><path>wishlist\/<\/path><label>My Wishlist<\/label><\/action-->/' ${FULLPATH}
						echo "Link removed"
esac

read -p "Remove My Downloadable Products link? (y/n)" yn
FILENAME="downloadable.xml"
FULLPATH="${THEME}${FILENAME}"
case $yn in
	[YyJj]* )           if [ -e ${FULLPATH} ]; then
						echo "File already exists; make modifications in existing file"
						else
						echo "File doesn't exist; copy first"
						mkdir -p `dirname ${FULLPATH}`
						cp ${BASE}${FILENAME} ${FULLPATH}
						fi
						sed -i 's/<action method="addLink" translate="label" module="downloadable"><name>downloadable_products<\/name><path>downloadable\/customer\/products<\/path><label>My Downloadable Products<\/label><\/action>/<!--action method="addLink" translate="label" module="downloadable"><name>downloadable_products<\/name><path>downloadable\/customer\/products<\/path><label>My Downloadable Products<\/label><\/action-->/' ${FULLPATH}
						echo "Link removed"
esac

read -p "Remove My Newsletter Subscriptions link? (y/n)" yn
FILENAME="newsletter.xml"
FULLPATH="${THEME}${FILENAME}"
case $yn in
	[YyJj]* )           if [ -e ${FULLPATH} ]; then
						echo "File already exists; make modifications in existing file"
						else
						echo "File doesn't exist; copy first"
						mkdir -p `dirname ${FULLPATH}`
						cp ${BASE}${FILENAME} ${FULLPATH}
						fi
						sed -i 's/<action method="addLink" translate="label" module="newsletter"><name>newsletter<\/name><path>newsletter\/manage\/<\/path><label>Newsletter Subscriptions<\/label><\/action>/<!--action method="addLink" translate="label" module="newsletter"><name>newsletter<\/name><path>newsletter\/manage\/<\/path><label>Newsletter Subscriptions<\/label><\/action-->/' ${FULLPATH}
						echo "Link removed"
esac

echo "Done!"

Viewing all articles
Browse latest Browse all 12

Trending Articles