News:

Looking for documentation? Take a look on our wiki

Main Menu

Random url in products

Started by Sillero, March 29, 2023, 13:02:17 PM

Previous topic - Next topic

Sillero

Hi, thanks to you all.

@ Pinochico. I understand, thank for all your tips and explanations.

I want to return a small contribution to the community for everything that has helped me in the past:

If someone has this same problem (in GSC many urls are crawled and indexed with the wrong route) you can do:

In simple products (without multivariants) you only have to check if the canonical url of the $document is the same as the base url. If not, apply the redirect to the canonical.

In products with multivariants, the same logic would be applied to the parent product, but in the children it is necessary to check if the base url ($document->base) is different from the canonical one of the child product (which is not the same as the one of the product when it is shown - if the option to use the parent as canonical url is activated in the custom field) that is to say in $this->product->canonical. In that case apply the redirect to the canonical url of the child (JRoute::_($this->product->canonical))
In this way, random urls will not continue to be generated. The only catch is that if a product appears in several categories, when entering it you will be redirected to the canonical category. This is something I need to fix but it's a big step.
In my opinion Virtuemart should implement this somehow since a lot of crawl budget is spent and many unnecessary urls are indexed.
Thanks!!