Override Default Category action method of Catalog Controller using Plugin

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
8 years ago
I need to override default Category action method of Catalog Controller.

Here is RouteProvider inside the plugin:



        public void RegisterRoutes(RouteCollection routes)
        {

            routes.MapLocalizedRoute("Nop.Plugin.APEX.Catalog.OverridenCategory",
                "{SeName}",
                new { controller = CONTROLLER, action = "OverridenCategory"},
                new[] { NAMESPACES });

        }

        public int Priority
        {
            get
            {
                return 20;
            }
        }




Here is CatalogController inside the plugin:

      
public partial class CatalogController : Nop.Web.Controllers.CatalogController
{
       [ActionName("OverridenCategory")]
        [NopHttpsRequirement(SslRequirement.No)]
        new public ActionResult Category(int categoryId, CatalogPagingFilteringModel command)
        {
         //
        //
        //
        }
}



But when I run the code I see an error as follows:


The parameters dictionary contains a null entry for parameter 'categoryId' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Category(Int32, Nop.Web.Models.Catalog.CatalogPagingFilteringModel)' in 'Nop.Plugin.APEX.Catalog.Controllers.CatalogController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters

Any idea how to convert "{SeName}" into {categoryId}?
8 years ago
Any updates? I am facing the same problem.

This is my route:

var route = routes.MapLocalizedRoute("Nopaholics.Filter.CategoryFilterzzzzzz",
                         "{SeName}",
                         new { controller = "OverrideCategory", action = "Category_New" },
                         new[] { "Nopaholics.Filter.Controllers.OverrideCategoryController" });


I even tried

var route = routes.MapLocalizedRoute("Nopaholics.Filter.CategoryFilterzzzzzz",
                         "{SeName}",
                         new { controller = "OverrideCategory", action = "Category_New" },
                         new[] { "Nopaholics.Filter.Controllers" });


Thanks.
8 years ago
Please follow the last two steps of this link https://www.nopcommerce.com/boards/t/41173/how-to-override-genericpathroutegetroutedata-in-plugin.aspx. He faced the same issue. It will work for override generic rout from plugin.
8 years ago
Does not contain a definition for 'CustomGenericPathRoute'.
What reference do I need to add??

Thanks
8 years ago
nsharma wrote:
Does not contain a definition for 'CustomGenericPathRoute'.
What reference do I need to add??

Thanks


Please check you Private Message.
8 years ago
I did everything as described and I just changed the following code:

data.Values["controller"] = "WidgetsBrowse";
data.Values["action"] = "categoryNew";

Still I am getting the same error. Do I need to change anything else?

Thanks
8 years ago
nsharma wrote:
I did everything as described and I just changed the following code:

data.Values["controller"] = "WidgetsBrowse";
data.Values["action"] = "categoryNew";

Still I am getting the same error. Do I need to change anything else?

Thanks


Can you please give me your email address? I want to send you the working code that I implement at my plugin. Is it possible to send email address?
7 years ago
[email protected]
7 years ago
[email protected]
7 years ago
harshitporwal wrote:

@harshitporwal Do you want the related files?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.