Removing SEO Terms and Advanced Search Links from Magento Footer
In Magento, removing links like “Popular search terms” or “Advanced search” from the footer requires a strategic approach that ensures upward compatibility during future upgrades. Let me walk you through the correct method using local.xml.
Understanding the Current Setup
The default configuration for these footer links is found in catalogsearch.xml file under <reference name="footer_links">. However, it’s important to note that this block doesn’t have a “name” attribute like some others. This means altering it directly might not be upward compatible.
The code for the search terms and advanced search links looks like this:
<reference name="footer_links">
<action method="addLink" translate="label title"
module="catalogsearch"
ifconfig="catalog/seo/search_terms">
<label>Search Terms</label>
<url helper="catalogsearch/getSearchTermUrl"/>
<title>Search Terms</title>
</action>
<action method="addLink" translate="label title"
module="catalogsearch">
<label>Advanced Search</label>
<url helper="catalogsearch/getAdvancedSearchUrl"/>
<title>Advanced Search</title>
</action>
</reference>
The Correct Approach: Using local.xml
The key to a maintainable solution is leveraging the power of app/design/frontend/<your_package>/<your_theme>/layout/local.xml. This file allows you to override layouts without touching core files. Here’s how to do it:
-
Create or open your
local.xmlfile in the specified path. -
Add the following code inside the
<layout>tags:
<reference name="footer_links">
<action method="removeLink" ifconfig="catalog/seo/search_terms">
<name>Search Terms</name>
</action>
<action method="addLink" translate="label title"
module="catalogsearch">
<label>Advanced Search</label>
<url helper="catalogsearch/getAdvancedSearchUrl"/>
<title>Advanced Search</title>
</action>
</reference>
In this code:
- We use the
removeLinkaction to remove the “Popular search terms” link, which is controlled bycatalog/seo/search_terms. - We leave the “Advanced Search” link as it is, but we wrap it in an
<action>block for better control.
Removing the Site Map Link
Similarly, if you want to remove the “Site map” link:
- Add this code inside your
local.xml:
<reference name="footer_links">
<action method="removeLink"><name>Sitemap</name></action>
<!-- Rest of the existing code -->
</reference>
- Save and flush cache to see the changes in your frontend.
Why This Method Works
This approach is upward compatible because it doesn’t modify any core files directly; instead, it uses Magento’s built-in layout XML structure. This means you won’t have conflicts during future upgrades.
Moreover, using local.xml allows for easier maintenance and readability of your codebase.
Remember to flush the cache after making changes to see them take effect in the frontend. You can do this from the System menu in the admin panel or by running bin/magento cache:flush from the command line.
Conclusion
Removing footer links like “Popular search terms” and “Advanced Search” in Magento requires a strategic approach that prioritizes upward compatibility. By leveraging local.xml, you can achieve this without touching core files, ensuring your website remains maintainable during future upgrades.
For more advanced customizations and troubleshooting tips, consider checking out the Magento 2 Development Guide for a comprehensive resource on Magento development practices.