In a plugin -
I am trying to alter the logic in the PrepareProductDetailsPageModel method of product controller. As such, I am trying to override the route of ProductController
routes.MapLocalizedRoute("XXX.Plugin.Misc.Core.Controller.Product",
"{SeName}",
new { controller = "Product", action = "ProductDetails" },
new[] { "XXX.Plugin.Misc.Core.Controllers" }
);
My product controller inherits Nop.Web.Controller.ProductController and overrides the PrepareProductDetailsPageModel method.
I could not get overriding the route to work, because of the MapLocalizedRoute causing a "The parameters dictionary contains a null entry for parameter 'productId' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult ProductDetails(Int32, Int32)' in 'Nop.Web.Controllers.ProductController'" error when I try to override the route.
I have tried copying GenericPathRoute.cs and GenericPathRouteExtensions.cs to my plugin folder and modifying it to use the namespace of my controller but that has not been a success.
After lots of playing and research, it seems that the only effective way to "override" the Product Controller is by use of Action Filters. Is this statement true?
I absolutely do not want to alter the core code as this plugin will be used in multiple sites, one on 3.4 and one on 3.5 and I want to make the upgrade path as smooth as possible to 3.6. (and future).
Please advise. Has anyone successfully overridden the Product Controller in a plug in? Are filters my only option?
Am I missing something?
If anyone has any other tips please advise.