Magento 2

Magento2 add a cms page link to menu

Magento2 add a cms page link to menu

.
Magento2 add a cms page link to menu or add a link to the menu, Magento2 add a cms page link to the menu.

Most of the times, need to add cms page links or static link to the menu.T

So, today I am writing this blog for add a cms page link to the menu at magento2.In this case, i am using Magento plugins and use before method.

We have used class Magento\Theme\Block\Html\Topmenu  as the menu is rendered from this class and use before plugin.

and use before plugin on _getHtml()

Magento2 add a cms page link to menu
Magento2 add a cms page link to menu

First, create a module.

Second: create di.xml where we will define the plugin.

app\code\{VendorName}\{ModuleName}\etc\di.xml

3.Now create the plugin class where we will add a cms page link to the menu.

File Path: app\code\{VendorName}\{ModuleName}\Plugin\Topmenu.php

In this way, you can Magento2 an add custom link to menu or navigation.

This module should have below files:

In this example, I have added contact us page AT the menu.

Hope this blog will help the people

Related posts:

 

 

 

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *