nopAccelerate

Faster, scalable and reliable nopCommerce.

How to add a menu item into the administration area of nopCommerce from a plugin?

FacebooktwitterredditpinterestlinkedinmailFacebooktwitterredditpinterestlinkedinmail

If you’re a nopCommerce developer, you’ll find yourself using nopCommerce plugins to add your custom features into the nopCommerce. While nopCommerce IAdminMenuPlugin doesn’t allow to add your custom menu items under its default menu items, you can still add your custom menu items into Plugins menu.

In nopCommerce, administration menu is build from the Sitemap.Configuration file which is located in Nop.Admin folder. To add your custom menu items in nopCommerce administration panel, you can add it by extending SitemapNode class of nopCommerce.

To do the same, you can use following sample code which you need to add in your plugins’ cs file, after your plugin’s Install and Uninstall method.

    public bool Authenticate()
        {
            return true;
        }

     public  SiteMapNode BuildMenuItem() // SiteMapNode is Class in Nop.Web.Framework.Menu
        {
            var menuItemBuilder = new SiteMapNode()
            {
                Title = "Title For Menu item",   // Title for your Custom Menu Item
                Url = "Path of action link", // Path of the action link
                Visible = true,
                RouteValues = new RouteValueDictionary() { {"Area", "Admin"} }
            };

         var SubMenuItem = new SiteMapNode()   // add child Custom menu
            {
                Title =  "Title For Menu Chile menu item", //   Title for your Sub Menu item
                ControllerName = "Your Controller Name", // Your controller Name
                ActionName = "Configure", // Action Name
                Visible = true,
                RouteValues = new RouteValueDictionary() { {"Area", "Admin"} },
            };
            menuItemBuilder.ChildNodes.Add(SubMenuItem);

            return menuItemBuilder;

        }

In the above code, you can find comments where you need to replace values depending on your requirements. Moreover, the above code also explains how you can add a child menu items inside main menu.

Note that this code is tested to work on nopCommerce 3.40. Moreover, if you find any issue or need help, feel free to post it into comments or use nopCommerce forum.

FacebooktwitterredditpinterestlinkedinmailFacebooktwitterredditpinterestlinkedinmail

One Comment

  1. Isra-
    July 9, 2015 at 11:45 am

    define steps to add custom manu and child menu i am biggner for Nopcommerce

Fill in form

and we will contact you

How can we help ?

Schedule a quick call, 15-minute meeting with one of our experts:

Thank You !

Our consultant will contact you in 24 hours.

Delivering generous mobile apps for Entrepreneurs, Startups & Businesses


Have a look at nopAccelerate Demo Store with 80,000+ products with nopAccelerate Solr and CDN Plugin.

download-trial Start Trial