Seo Addon - 301 Redirects - Making Them Work When Object Exists With Same Uri

Hey all. The behavior of 301 redirects in CS-Cart doesn't make sense to me. There is a message on that says:

A redirect from an object will work only if this object was not found. A disabled object still exists, even though it can’t be viewed on the storefront. That’s why the redirect from that object won’t work. But if you delete the object or change its SEO name, the redirect will work.

Curious if anyone knows how to bend that behavior to allow objects to be redirected regardless of their status? What i mean is if a product/cat/page/etc exists and has a URi redirect-this.html, i want to be able to redirect that URi using the 301 manager regardless of whether the object exists.

/app/addons/seo/func.php (fn_seo_get_route) hooks fn_get_route() in /app/functions/fn.control.php which sets $result as INIT_STATUS_REDIRECT. However, once you dig into that hook it becomes slippery to nail down. For example im hung up on a few thoughts:

- $is_allowed_url is named funny, seems confusing off the bat. If is_allowed_url is false then redirect request is true. Feels like its missing some kinda $objects['type'] check somewhere that could solve this, although everywhere i tried caused looping, or another 301 to homepage after success, or other estranged behavior due to wrong check order, lack of type, or multiple loops explained below.

- $objects array is populated with different values in different loops. Seems like there should be just 1 loop based on 1 array, not redundant checks for different styles of arrays. This lead me back to the regex, but messing with that might erase some kinda compat im not aware of as to why the other $objects array is needed.

- In a product uri like redirect-this.html there are 2 loops searching the seo_names table based on 2 variations of $objects arrays. They are looking in there for something ending in .html, however the object names are stored without the .html (even if master seo rule says append it on object url). It seems strange to go through there, essentially twice doing the same check in a different way, but maybe im missing something?

I honestly figured this would be a pretty easy fix, but after seeing the giant redir hook, all its temp array maps, and strange multiple loops, i am requesting backup :) Code 2 flow PDF attached.

Thanks for your time all.


If this will help, here is a priv dump of the commented /seo/func.php seo_route hook i got so far. Notes are raw dog. something.html references may differ but $objects array and loop counts are same, i dont have time to edit it atm but may change in the next few :)

$i is primary loop, $ii is secondary validate. I was testing with product + category objects, and a mask seo_name for login (as login.html to hit alternate table array/loop)

The x_r() dump function is here:

Lets solve this!

CS cart rocks had a canonical redirect seo addon that redirected the url regardless of the status, or if disabled. Check with them they may be able to put something together