'Why is PrestaShop redirrecting to a random product when selecting variations from front-end?

I have an online shop in development, all went well until I decided to do SEO on the shop. After this, if I chose a product variation from front-end it just redirects me to a random product.

enter image description here This picture describes the first state. The default product load.

enter image description here This picture describes what is happening after you select a variation. As you can see the product name stays the same, but the link indicates that a totally different product is displayed.

If I have the debug mode enabled when selecting a variation it throws "An error occurred while processing your request" and in the request file I can see that besides some errors (Deprecated: array_key_exists(): Using array_key_exists()) it shows the request for a different product.

I can't understand why this is happening, so I am in dying need of your help.



Solution 1:[1]

I found a fix for this. Apparently or appeared because I was using the duplicate function for uploading products. I don't know why but on some products it makes this behavior.

I've spent over 12 hours to find a explanation for this and I was unable to find one. The PrestaShop forum straight up banned me for posting this topic.

My advice is to NOT USE PRESTASHOP it's and old sistem and full of bugs, the support is expensive and I get the impression that even they don't understand their system.

If you find yourself in this situation, know this. Don't duplicate and upload products using "add new" function.

And I can't state this enough, do yourself a favour and don't use Presta, with all the expenses the time to invest and what the product looks like at the end of the road, is just a waste of time. Even after you finish is guaranteed to break in 1-2 years, any updates will break your store and you will need to invest even more more to fix it. It's an old, slow and buggy CMS. It's days are numbered.

Thanks a lot for help. Best regards, Daniel.

Solution 2:[2]

That's the way Prestashop 1.7 works :

First time a customer lands in a multi-variation page, the default attribute will be loaded, URL will show only the ID product.

Once you choose an attribute , an AJAX call will refresh the page with the current attribute and URL will change with id_product-id_product_attribute value.

Not sure what you mean by "random product" as in both of your examples I see an attribute being selected.

Anyway there are several (paid) modules to change this behaviour in a better SEO perspective, this is definitely one of the most famous :

https://addons.prestashop.com/en/url-redirects/16633-pretty-urls-seo-friendly-url-remove-ids-numbers.html

EDIT: Just noticed that the ID product is different in the two screenshot, this could be related to some DB issues with attribute too, you should check if you have some not coherent values between id_product and id_product_attribute(s)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gabriel Roman
Solution 2