[SOLVED] Misc Custom Plugin picking up wrong cshtml view

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
Hello everybody.

I have downloaded the source code for NopCommerce 2.65, loaded the solution into Visual Studio 2012 Express, followed the instructions of this page:

https://www.nopcommerce.com/docs/77/default.aspx

...and somehow ended up with a plugin stub whose solution and sources can be seen from the following Zip file:

[url= https://docs.google.com/file/d/0B0xs2YFff_jOZHQ2THJHbTB1LWc/edit?usp=sharing]https://docs.google.com/file/d/0B0xs2YFff_jOZHQ2THJHbTB1LWc/edit?usp=sharing[/url]

The plugin shows up correctly in the plugins list in the admin area, and from there I told nopCommerce to install it.

The issue is that when I click on the "Configure" link I get sent to this page:

http://localhost:2619/Admin/Plugin/ConfigureMiscPlugin?systemName=Misc.DataManager

...the HTML I see there does not come from the "Configure.cshtml" in my "Views" folder (which only holds a couple of HTML tags), instead, it appears to be coming from the MailChimp plugin's view.

Sure thing, I have copied some files and code from the MailChimp plugin and modified it to create the stub you can see in the above Zip file, only that as far as I can tell I haven't left any reference to the MailChimp plugin anywhere in my code.

Is it me missing some leftover or am I stomping on some cache / fallback issue, either in Visual Studio or in the nopCommerce system?

SOLVED thanks to keesjan and mb:

I had my GetConfigurationRoute in the main DataManager class not matching up with my DataManagerController.

Also, I had my DataManagerController and my SettingsModel classes missing the "public" access specifier.

Thanks a lot for the support, keep up the good work!

Bests,
Francesco
11 years ago
you are missing a SettingsController with action Index as returned by GetConfigurationRoute in the DataManager class
11 years ago
Hello keesjan, thanks for your reply.

I made the change you advised, actually I've also spent some time studying this tutorial in order to get more understanding of what I'm playing with:

http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/intro-to-aspnet-mvc-3

Here is the current status of my custom plugin stub:

https://docs.google.com/file/d/0B0xs2YFff_jONW1MYmNFT01mNVE/edit?usp=sharing

What happens now is that I get the same error lamented here:

https://www.nopcommerce.com/boards/t/18909/solved-the-controller-for-path-adminpluginconfiguremiscplugin-was-not-found-or-does-not-implement-icontroller.aspx

I checked the version of my System.Web.Mvc reference, which I added browsing for this file in the source of nopCommerce 2.65:

\packages\aspnetmvc\System.Web.Mvc.dll

The above reference reports "3.0.0.0" as Version and "v4.0.30319" as Runtime Version, just like the same reference in the other plugins do, so I guess that's not the cause of my issue.

On the base of the comment there mentioning to browse to the view directly I added a RouteProvider.cs with this code:

using System.Web.Mvc;
using System.Web.Routing;
using Nop.Web.Framework.Mvc.Routes;

namespace Nop.Plugin.Misc.DataManager
{
    public class RouteProvider : IRouteProvider
    {
        public void RegisterRoutes(RouteCollection routes)
        {
            routes.MapRoute("Plugin.Misc.DataManager.Settings", "Plugins/MiscDataManager/Settings",
                            new { controller = "MiscDataManager", action = "Index" },
                            new[] { "Nop.Plugin.Misc.DataManager.Controllers" }
                );
        }

        public int Priority
        {
            get { return 0; }
        }

    }
}


then tried navigating to...

http://localhost:2619/Plugins/MiscDataManager/Settings
(edited, I omitted the "Plugins" part in the first edit of this post)

...and hit a 404.

At this point, instead of asking what's wrong with my code, I wonder whether I should ask about which tutorials / documentation I should really pass through before ever thinking about creating a plugin for nopCommerce.

Thanks again for your attention,
bests,
Francesco
11 years ago
You need to set the access modifier for your controller and SettingsModel classes to public.

Edit file: Nop.Plugin.Misc.DataManager\Controllers\MiscDataManagerController.cs
change the following line:
class MiscDataManagerController : Controller

to:
public class MiscDataManagerController : Controller

Edit file: Nop.Plugin.Misc.DataManager\Models\SettingsModel.cs
change the following line:
class SettingsModel : BaseNopModel
to:
public class SettingsModel : BaseNopModel

Rebuild the project and click the 'Reload list of plugins' button on Admin > Configuration > Plugins and your plugin's Configure link should work.

.
11 years ago
Hello mb, thanks for your reply, applying the changes you pointed out got me back on track.

Bests,
Francesco
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.