Jump to content

Friendly url generate failed


Eros eros

Recommended Posts

Hi, i have many product that have in Friendly url this value 'friendly-url-autogeneration-failed' but the product name is present and also well formed, why?
This issue does not affect all products in my catalog but also affects some products, but I have not understood the cause. Isn't there a way to automatically regenerate them?

Link to comment
Share on other sites

Hi,

This issue occurs when PrestaShop fails to generate a valid friendly URL for some products, often due to invalid characters.

To fix this, first, ensure that "Friendly URLs" is enabled in Shop Parameters > Traffic & SEO, then edit and re-save affected products in Catalog > Products to regenerate their URLs.

If products are affected, regenerate their URLs with this PHP script:

foreach (Db::getInstance()->executeS("SELECT id_product, name FROM ps_product_lang WHERE link_rewrite = 'friendly-url-autogeneration-failed'") as $p) {
Db::getInstance()->execute("UPDATE ps_product_lang SET link_rewrite = '".Tools::link_rewrite($p['name'])."' WHERE id_product = ".(int) $p['id_product']);
}

Kindly include the correct detail in place of 'friendly-url-autogeneration-failed' in the above query.

After updating, clear the cache from Advanced Parameters > Performance and reindex the database to apply changes.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...