Migrating plugins to NopCommerce 4.0: How is the configuration controller linked tot the configuation page url

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
I am currently in the process of migrating my nop 3.90 plugins to nop 4.0

My first issue is that when I attempt to open the configuration page of my plugin, nopcommerce throws a 404 page not found.

How is the configuration page url to controller wiring established?

My plugin class contains this code:


    /// <summary>
    /// PLugin
    /// </summary>
    public class LicenseManagerPlugin : BasePlugin, IMiscPlugin
    {
        private readonly IWebHelper _webHelper;

        public LicenseManagerPlugin(IWebHelper webHelper)
        {
            _webHelper = webHelper;
        }

        /// <summary>
        /// Gets a configuration page URL
        /// </summary>
        public override string GetConfigurationPageUrl()
        {
           return $"{_webHelper.GetStoreLocation()}Admin/Misc.LicenseManager/Configure";
        }
    }


When the plugin list is loaded, I see my plugin in the list and  GetConfigurationPageUrl() is called

Next I have a controller with the name: MiscLicenseManagerController


   [Area(AreaNames.Admin)]
    public class MiscLicenseManagerController : BasePluginController
    {
        ...

        public IActionResult Configure()
        {
            return View("~/Plugins/Misc.LicenseManager/Views/Configure.cshtml");
        }
    }


I do not have a RoutingProvider class as the standard NopCommerce plugins also lack this class.

My plugin is stored in  \Presentation\Nop.Web\Plugins\Misc.LicenseManager

The plugin is loaded.

However nopCommerce can not find the controller based on the url.

Is there some magic that I dont yet understand?
6 years ago
actOpus wrote:
I am currently in the process of migrating my nop 3.90 plugins to nop 4.0

My first issue is that when I attempt to open the configuration page of my plugin, nopcommerce throws a 404 page not found.

How is the configuration page url to controller wiring established?

My plugin class contains this code:


    /// <summary>
    /// PLugin
    /// </summary>
    public class LicenseManagerPlugin : BasePlugin, IMiscPlugin
    {
        private readonly IWebHelper _webHelper;

        public LicenseManagerPlugin(IWebHelper webHelper)
        {
            _webHelper = webHelper;
        }

        /// <summary>
        /// Gets a configuration page URL
        /// </summary>
        public override string GetConfigurationPageUrl()
        {
           return $"{_webHelper.GetStoreLocation()}Admin/Misc.LicenseManager/Configure";
        }
    }


When the plugin list is loaded, I see my plugin in the list and  GetConfigurationPageUrl() is called

Next I have a controller with the name: MiscLicenseManagerController


   [Area(AreaNames.Admin)]
    public class MiscLicenseManagerController : BasePluginController
    {
        ...

        public IActionResult Configure()
        {
            return View("~/Plugins/Misc.LicenseManager/Views/Configure.cshtml");
        }
    }


I do not have a RoutingProvider class as the standard NopCommerce plugins also lack this class.

My plugin is stored in  \Presentation\Nop.Web\Plugins\Misc.LicenseManager

The plugin is loaded.

However nopCommerce can not find the controller based on the url.

Is there some magic that I dont yet understand?


Try==>


  /// <summary>
        /// Gets a configuration page URL
        /// </summary>
        public override string GetConfigurationPageUrl()
        {
            return _webHelper.GetStoreLocation() + "Admin/MiscLicenseManager/Configure";
        }

6 years ago
Nope, that did not work. Did that at first after migrating. Besides that, all standard plugins use Interpolated Strings and there is nothing wrong with that.


Oddly enough, it seems to work now
6 years ago
It now turns out that the plugin was somehow discarded since one of the internal services had a autofac registration of .InstancePerRequest()

After changing that to .InstancePerLifetimeScope() the controller was loaded.
6 years ago
actOpus wrote:
Nope, that did not work. Did that at first after migrating. Besides that, all standard plugins use Interpolated Strings and there is nothing wrong with that.


Oddly enough, it seems to work now


Check your code ==>Controller Name => I suggest to correct it nothing else


$"{_webHelper.GetStoreLocation()}Admin/Misc.LicenseManager/Configure"



Note: Use it: MiscLicenseManager
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.