Customising the Product URL

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 12 ans
Hi Guys

I have been messing around with nop this evening. I was trying to remove the product ID & p/ from the product URL.

I was planning to try and direct the routes to a custom controller to handle the product lookup. I do appreciate it's not going to be as efficient as looking up ID but am interesting in doing it.

I tried the below and set it as a low priority route (so the static routes still fire correctly).

It creates the desired URL's but it triggers the 404 page when clicked.

If I comment out the new { productId = @"\d+" }, it appends the productId as a querystring but navigates correctly to the product page and I can retrieve the SeName parameter for lookup.

routes.MapLocalizedRoute("Product",
                            "{SeName}",
                            new { controller = "CustomController", action = "Product" },
                            new { productId = @"\d+" },
                            new[] { "Nop.Web.Controllers" });

Anyone got any ideas, or I am approaching this the wrong way?

I am using nop 2.3
Il y a 12 ans
Did you ever got a reply or a fix to this problem ?

I noticed that the controller seems to take the ProductID value
and use that to pick up the actual record on the DB.

that means that if you have
http://www.winepassionate.com/p/19/wine-chianti-docg-la-moto

And you change the value 19 to something else, a different product is loaded,
even if the SENAME remains the same.

So I guess we should find a way to pass the ID differently to the controller.
Il y a 12 ans
chease wrote:
Hi Guys

I have been messing around with nop this evening. I was trying to remove the product ID & p/ from the product URL.

I was planning to try and direct the routes to a custom controller to handle the product lookup. I do appreciate it's not going to be as efficient as looking up ID but am interesting in doing it.

I tried the below and set it as a low priority route (so the static routes still fire correctly).

It creates the desired URL's but it triggers the 404 page when clicked.

If I comment out the new { productId = @"\d+" }, it appends the productId as a querystring but navigates correctly to the product page and I can retrieve the SeName parameter for lookup.

routes.MapLocalizedRoute("Product",
                            "{SeName}",
                            new { controller = "CustomController", action = "Product" },
                            new { productId = @"\d+" },
                            new[] { "Nop.Web.Controllers" });

Anyone got any ideas, or I am approaching this the wrong way?

I am using nop 2.3


You should uncomment the route debugger found in Global.asax. This will show you which routes are getting hit and which routes might be catching what you perceive to match ONLY this pattern.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.