Create friendly URL based on product name in Prestashop using SQL query

Below you will find simple SQL queries which creates product friendly url from product’s name and saves them in the database SEO section.

You can run this i.e. in phpmyadmin or MySQL Workbench.

Example of action

From product name $ My super product 1 !!! it will create friendly url my-super-product-1

Queries

This queries will create friendly URLs for all products in the shop:

I ask you to review this article

Rating 5 Stars from 2 reviews

19 thoughts on “Create friendly URL based on product name in Prestashop using SQL query”

  1. Hello,

    Thanks for your post 🙂

    It’s possible to create a cron for this sql query ?

    Regards

    1. Hello,

      If you want to create cron you need to create a script with query from post above, eg. create_friendly_url.php
      Next add executing of this file in cron like this: php /path/to/file/create_friendly_url.php

      Maybe my module will help you: https://github.com/evox95/mbgplr

      If you want me to write such a cron task for you, write to me: [email protected]

      Regards

  2. Hello,
    Thank you for your article.
    Would you have the same query to update all descriptions produced from one language (FR id 1) to all other languages (X6)?
    Thanks

  3. Hello,
    Thanks again for your scripts!
    I have a problem with your module that generates the product URLs.
    When a product has a character accented in its name (French name), the rewritten url stops literally before that accent.
    Do you have a solution to avoid this problem?
    Thank you in advance.

  4. In fact, it’s the apostrophes that are problematic …
    Ex: name of product is VEILLEUSE PROJECTEUR D’ÉTOILES
    and the url rewrite is truncated before ‘ÉTOILES
    Would you have a solution?

  5. yes it’s the same result
    My product name is : VEILLEUSE PROJECTEUR D’ÉTOILES
    And the URL friendly is (with your module or your sql code) : veilleuse-projecteur-d
    I would like URL friendly : veilleuse-projecteur-d-étoiles

    Thanks

  6. Hello,
    Sorry for my english I’m french 🙂
    How can I have the right URLs for my products by keeping accented characters?
    I’m going around in circles since yesterday …
    Thank you in advance for your help.
    Bruce

  7. Hello,
    How can I transform accented uppercase characters in accented lowercase characters?
    Thanks a lot for your help.
    Bruce

  8. Hello,
    You don’t have any ideas for transform accented uppercase characters in accented lowercase characters ?
    Thanks
    Bruce

    1. Hello,
      My script removes everything which is not not number (0-9) or small letter (a-z) and replaces uppercase letters (A-Z) into lowercase (a-z).
      I think it’s not a good idea to have accented characters in URL.
      If you want I can add replacing accented characters into standard ASCII characters (a-z).

  9. “If you want I can add replacing accented characters into standard ASCII characters (a-z).”

    Yes, I would like it if you do not mind. 🙂

  10. At worst, we turn uppercase accented characters letters into lowercase characters not accented

  11. Hello,
    I try this :
    IF i >= 192 AND i <= 223 THEN
    ITERATE label;
    END IF;
    But is not good 🙁
    Product name : POKÉBOX NOËL 2017
    Url rewrite : pokÉbox-noËl-2017
    I would like : pokébox-noël-2017 or pokebox-noel-2017

    Thanks
    Bruce

  12. Thanks but this query so long…
    And if we transform accuented characters uppercase to characters lowercase(a-z) what’s the query ?

  13. Hello,
    Please, could you help me to transform accented characters uppercase to characters lowercase (a-z) ?

Leave a Reply

Your email address will not be published. Required fields are marked *

twenty − seventeen =