UrlRecordService and redirecting

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

I had a quick check, but sorry if this is already reported - I know that redirecting is being looked at for 3.80 and want to report an issue that's been uncovered by our Redirect Plugin that will help develop this area:

In the UrlRecordService

line216
public virtual UrlRecordForCaching GetBySlugCached(string slug)


line96
protected virtual IList<UrlRecordForCaching> GetAllUrlRecordsCached()

They load IsActive "false" records into the cache - logically this doesn't make sense, but this can be a confusion as nopCommerce doesn't make the record inactive when deleting a product, so how to did they get inactive? Maybe a previous developer, I'm not sure, but the logic is still there - I believe it would be best not to load the IsActive "false" records into the cache - We're adding a work-around to the plugin to deal with clients who do/have done this. Not sure what your take on this would be?

It seems a product was created, had it's seo name changed and then was deleted - leaving the record? the isactive record is loaded into the cache but the product is deleted -

but logically the IsActive false records actaully should be loaded into the cache as they are then 302 redirected by nopCommerce -  but this product is gone. It does get confusing :-)

Thank you,
8 years ago
Hi Marc,

It's by design. If you need an active slug, then you should use "GetActiveSlug" method. And "GetAllUrlRecordsCached" should load all records (including inactive ones).

Loading of inactive records is used in the "GetRouteData" method of \Nop.Web.Framework\Seo\GenericPathRoute.cs (we invoke "GetBySlugCached" method that invokes "GetAllUrlRecordsCached"). If a loaded UrlRecord is inactive (e.g. when "Search engine friendly page name" of a product has been changed by a store owner), then we can process an old URL with "301" redirection to a new URL (to a new "Search engine friendly page name")
8 years ago
Thank you Andrei, that does make sense, thanks for clarifying the intention as well. I've made a temporary fix for the plugin, but I'll look deeper and update accordingly and follow the progress for the next version...
4 years ago
a.m. wrote:
Hi Marc,

It's by design. If you need an active slug, then you should use "GetActiveSlug" method. And "GetAllUrlRecordsCached" should load all records (including inactive ones).

Loading of inactive records is used in the "GetRouteData" method of \Nop.Web.Framework\Seo\GenericPathRoute.cs (we invoke "GetBySlugCached" method that invokes "GetAllUrlRecordsCached"). If a loaded UrlRecord is inactive (e.g. when "Search engine friendly page name" of a product has been changed by a store owner), then we can process an old URL with "301" redirection to a new URL (to a new "Search engine friendly page name")


This i actually great news i didnt know of. Buts is the 301 redirect done today by Nop or is it something i need to implement on my own?

Nicke
4 years ago
NicLas wrote:


This i actually great news i didnt know of. Buts is the 301 redirect done today by Nop or is it something i need to implement on my own?

Nicke


If you old url available in UrlRecord table then you not need to do anything extra.
nopCommerce already redirecting user from old entity url to new url.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.