4

I am trying to make my product url-keys in capital letters. Even if I update it manually it is still showing all in lower case letters. Upon checking the url-key after saving the product again it is auto saved in lower case. Is there anything I can do to force all product urls to be in capital letters?

  • That the url keys are in lower case happens here: \Magento\Framework\Filter\TranslitUrl::filter that's probably a good starting point. Be aware if you change the strtolower to strtoupper it will apply to all url keys (e.g. categories). You might have to add a new filter to \Magento\Framework\Filter\Factory and use this specific one for all product url key generations – Daniel Dec 10 '19 at 13:15
  • I've tried to change the functio as you suggested from strtolower to strtoupper but I receive: Unique constraint violation found when I try to save a product with the new url-key. I believe this is due to the fact that I have to truncate the tables catalog_url_rewrite_product_category and URL_rewrite still not sure dough. – Serco33 Dec 11 '19 at 14:22
  • This might be because the same url key is already present just in lower case (I had this problem). You could try deleting the key and save the product then magento should generate one in upper case. But as I said if you change it in this function be aware you'll change all generated urls because magento is using it for categories as well. – Daniel Dec 11 '19 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.