How can I add a submenu in admin panel under a existing menu in NopCommerce 3.8?

940 Views Asked by At

My question is almost similar like this question except a little bit change. There is a solution for adding menu, like I also want to add menu but in a different process.

Currently I am developing a project on combo promotional offer. So therefore I want to add a sub menu under Promotion Like all other submenus image

But what I have developed is creating a separate menu named Plugins and adding a submenu there. Like this image

And here is the code I have used for creating that menu.

public void ManageSiteMap(SiteMapNode rootNode)
        {
            var menuItem = new SiteMapNode()
            {
                SystemName = "Promotion.Combo",
                Title = "Combo Offer",
                ControllerName = "PromotionCombo",
                ActionName = "Configure",
                Visible = true,
                RouteValues = new RouteValueDictionary() { { "area", null } },
            };
            var pluginNode = rootNode.ChildNodes.FirstOrDefault(x => x.SystemName == "Third party plugins");
            if (pluginNode != null)
                pluginNode.ChildNodes.Add(menuItem);
            else
                rootNode.ChildNodes.Add(menuItem);
        }

I would like to know from which SystemName shall I add this submenu?

1

There are 1 best solutions below

4
On BEST ANSWER

You can use:

public void ManageSiteMap(SiteMapNode rootNode)
{
    var menuItem = new SiteMapNode()
    {
       SystemName = "Promotion.Combo",
       Title = "Combo Offer",
       ControllerName = "PromotionCombo",
       ActionName = "Configure",
       IconClass = "fa-dot-circle-o"
       Visible = true,
       RouteValues = new RouteValueDictionary() { { "area", null } },
    };

    var pluginNode = rootNode.ChildNodes.FirstOrDefault(x => x.SystemName == "Promotions");
        if (pluginNode != null)
            pluginNode.ChildNodes.Add(menuItem);
        else
            rootNode.ChildNodes.Add(menuItem);
}

System name you looked for is

Promotions

Updated answer to show you can use the IconClass in your menuItem object to add the icon in front of the menu item name.

Also, just for completeness, don't forget to add IAdminMenuPlugin to your plugin cs file, like so:

public class MyCustomPlugin : BasePlugin, IAdminMenuPlugin