Overriding SlugRouteTransformer TransformAsync in my plugin doesn't work in 4.5 was working in 4.4

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
1 ano atrás
nopCommerce Version: 4.5

Steps to reproduce the problem:
Why I am doing so: I want to override this method in the catalog controller
public override async Task Category(int categoryId, CatalogProductsCommand command)

For this matter, I have to override the slugrouteTransformer but it is not hitting, it's always going to the Nop.Web.Framework.Mvc.Routing.SlugRouteTransformer

Code snippets:

public class MyCustomRouteTransformer : DynamicRouteValueTransformer
{
public override async ValueTask TransformAsync(HttpContext httpContext, RouteValueDictionary values)
{
.......
switch (urlRecord.EntityName.ToLowerInvariant())
{
case "category":
values[NopPathRouteDefaults.ControllerFieldKey] = "MyCustomCatalog";
values[NopPathRouteDefaults.ActionFieldKey] = "Category";
values[NopPathRouteDefaults.CategoryIdFieldKey] = urlRecord.EntityId;
values[NopPathRouteDefaults.SeNameFieldKey] = urlRecord.Slug;
break;

            default:

     }
}

Nopstartup.cs:
services.AddScoped();

RouteProvider.cs:
public void RegisterRoutes(IEndpointRouteBuilder endpointRouteBuilder)
{

        var genericPattern = $"/{{SeName}}";
        endpointRouteBuilder.MapDynamicControllerRoute<CustomSideRouteTransformer>(genericPattern);
}

public partial class MyCustomCatalogController : CatalogController
{
public override async Task Category(int categoryId, CatalogProductsCommand command)
{
my code

}
}

THanks
Aditya
1 ano atrás
Hi, did you find the solution?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.