On 2/26/2020 at 8:21 PM, elshekar said:Exactly the same case here. Every time I clone a product I have to remember to go and press de REGENERATE button.
Plus, I have two languages, so when I upload a list of for example 1000 new products, the first time generates in both languages the same friendly-url. When I upload another list with the second language, all the products are translated but the friendly-url is still the same for both languages. I have to press the regenerate button for every single product. It's a waste of time if I have thousands of products! There's no solution?
Should I open a new post?
Its a pitty that even after 2 years there is not "RIGHT" answer to this question.
I have exactly the same problem. I have a lot of products duplicated and users forget to click on the button Generate because it is in the another section when they duplicate product, it is not obvious on the first. So we REALLY do not need to regenerate .htaccess file it is nonsense in this case. We really need automatic generation of friendly URLs.
First I have to say that this is a big error of the prestashop 1.5. When user duplicate product then this MUST be generated automaticaly as a default. It should not be left on the user. Or at least it should be done as a checkbox but defaulty regenerate it.
Secondly I tried to rewrite it in the database as was noted here and it works. So the problem has very simple solution:
-
if needed once a time, use update statement on the database for table ps_product_lang on column link_rewrite, the update statement may be a little long because there is not so simple to translate all accented chars to without accent but here is already created solutions (https://stackoverflow.com/questions/4813620/how-to-remove-accents-in-mysql 🙂 I have added the czech accents and minus sign and plus sign for the prestashop friendly URLs:
UPDATE ps_product_lang SET ps_product_lang.link_rewrite = LOWER(ps_product_lang.name),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,' ','-'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'+',''),ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'á','a'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ä','a'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'č','c'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ď','d'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'é','e'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ě','e'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'í','i'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ĺ','l'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ň','n'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ó','o'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ö','o'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ř','r'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'š','s'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ť','t'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ú','u'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ů','u'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ü','u'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ý','y'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ž','z'),ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Ð','Dj'),
and you can add or delete the chars that you want
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'À','A'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Á','A'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,' ','A'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Ã','A'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Ä','A'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Å','A'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Æ','A'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Ç','C'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'È','E'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'É','E'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Ê','E'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Ë','E'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Ì','I'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Í','I'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Î','I'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Ï','I'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Ñ','N'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Ò','O'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Ó','O'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Ô','O'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Õ','O'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Ö','O'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Ø','O'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Ù','U'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Ú','U'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Û','U'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Ü','U'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Ð','Dj'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Þ','B'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ß','Ss'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'à','a'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'â','a'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ã','a'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ä','a'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'å','a'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'æ','a'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ç','c'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ê','e'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ë','e'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ì','i'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'î','i'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ï','i'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ð','o'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ñ','n'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ò','o'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ô','o'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'õ','o'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ö','o'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ø','o'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ù','u'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'û','u'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ý','y'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'þ','b'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ÿ','y'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ƒ','f'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'œ','oe'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'Ł','L'),
ps_product_lang.link_rewrite = replace(ps_product_lang.link_rewrite,'ą','a'),
ps_product_lang.link_rewrite = trim(ps_product_lang.link_rewrite) - add a button to mass functions for list of products (like there is already button to delete selected), this is very simple solutions and you can regenerate it to any selected products
- create module that can be very simple just one button to regenerate all proudcts or very complicated that that can regenerate products by category, selected, or any other what you can think
- fix the prestashop by yourself it is opensource, so generate friendly url for clonning of product