How to Making a Menu in My Account menu on Magento 2 frontend?

Most of the time, as a Magento 2 extension developer, we have to dip our hands into both backend and frontend. In this blog, I will present to you how to make a Menu in customer’s My Account menu on frontend. I will use my example code in one of our module: GiftRegistry.

This picture denotes our expected outcome:

add menu on magento n2


We will create a database for the table, our table’s data will be from this database.

Make a file named magenest_registry_event in Setup/InstallSchema.php


Next up, create our table’s model: Model/Event.php




 This is where frontend components are handled frontend/layout/customer_account.xml.

This is the file which add a Tab named My Gift Registry in the My Account menu of a customer. The data will be passed onto giftregistry/customer/registry controller for handling. Make sure the path is correct. 

After that, we need to create one more layout file which will create a block and its template frontend/layout/giftregistry_customer_registry.xml

 Add frontend/templates/customer/gifregistry/list.phtml

This is the template file which add the table components and display it. You can customize it to suit your need.


Better late than never, lets create our controller file in Controller/Customer/Registry

This will put List Gift Registry as the title of the page.


This is one crucial part, make a file named Block/Customer/Registry/ListGift.php

This is the place where data will be received from database and handled then passed onto the template file to display.


Comments (5)

  1. Hunter Harpool
    Thanks bro , explanation is very good.
  2. Rames
    Hi this is blog is very use to me. But i want to display custom menu dependent upon customer type. how can i go that. can you please provide logic for that
  3. فروش پرینتر سه بعدی
    Fantastic website you have here but I was curious about if you knew of any message boards that cover the same topics talked about in this article? I'd really love to be a part of online community where I can get advice from other experienced people that share the same interest. If you have any suggestions, please let me know. Thanks!

Speak Your Mind

45 − = 41