Calling Plugin gives error. RouteProvider?

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

I'm having a problem on calling a simple hello world plugin. (Controller Action retruns a View)

Structure:

Pacoliba.Plugin.Catalog.ProductOverview
--- Controllers
------ CatalogProductOverviewController.cs
--- Models
--- Views
------ CatalogProductOverview
--------- ProductOverview.cshtml


This is the error i'm getting using - @Html.Action("GetProductOverview", "CatalogProductOverview") on the Index.cshtml of my theme:

The controller for path '/' was not found or does not implement IController.


RouteProvider:

namespace Pacoliba.Plugin.Catalog.ProductOverview
{
    class RouteProvider : IRouteProvider
    {

        public void RegisterRoutes(RouteCollection routes)
        {
            routes.MapRoute("Pacoliba.Plugin.Catalog.ProductOverview.GetProductOverview",
                 "Plugins/CatalogProductOverview/GetProductOverview",
                 new { controller = "CatalogProductOverview", action = "GetProductOverview" },
                 new[] { "Pacoliba.Plugin.Catalog.CatalogProductOverview.Controllers" }
            );

        }
        public int Priority
        {
            get
            {
                return 0;
            }
        }
    }
}


Controller - CatalogProductOverviewController.cs:

namespace Pacoliba.Plugin.Catalog.ProductOverview.Controllers
{
    class CatalogProductOverviewController : Controller
    {

        public ActionResult GetProductOverview(){

            return View("Pacoliba.Plugin.Catalog.ProductOverview.Views.CatalogProductOverview.ProductOverview");

        }

    }


}


View - ProductOverview.cshtml:

<div>
    hello world
</div>


As you can see, it's a quite simple example because i'm just getting started on developing plugins. Does someone knows what i'm doing wrong?

Kind Regards
11 years ago
I'm pretty sure you can't directly reference plugins like that from a theme.
11 years ago
Hi AndyMcKenna,

Thx for replying. Recently I've purchased an extension plugin form nop-templates.com and followed this documentation to implement. I was able to implement the filters in my theme using this bit of code:


@section nopAjaxFilters
{
        @Html.Action("GetFilters", "NopAjaxFilters")
}


So I've thought this was possible? I'm still getting the same error over and over again.

Kind Regards
11 years ago
No, it just looks like I'm wrong.
11 years ago
I'm fairly new to the MVC architecture, but learning as much as I can recently along with nopCommerce. (keep that in mind :))

In your route provider I think you have the namespace incorrect for your controller. The last argument for MapRoute() is a string array of namespaces, yours is:

new[] { "Pacoliba.Plugin.Catalog.CatalogProductOverview.Controllers" }


I think it should be:

new[] { "Pacoliba.Plugin.Catalog.ProductOverview.Controllers" }
11 years ago
weega wrote:
I'm fairly new to the MVC architecture, but learning as much as I can recently along with nopCommerce. (keep that in mind :))

In your route provider I think you have the namespace incorrect for your controller. The last argument for MapRoute() is a string array of namespaces, yours is:

new[] { "Pacoliba.Plugin.Catalog.CatalogProductOverview.Controllers" }


I think it should be:

new[] { "Pacoliba.Plugin.Catalog.ProductOverview.Controllers" }


Hi weega,

Thx for replying. You were right about the namespace of my plugin, but i'm still getting the same error after changing. Strange...
Is there someone who has developed a simple plugin so i can take a look at the code?

Kind regards.
11 years ago
Did you see this post? Make sure you restart your application from the admin.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.