URL Key characters conversion

Last modified by Michael on Thu, June 24, 2010 16:27
Source|Old Revisions  

This is an old revision of the document!


Product URL Key

Product URL Key is prepared in catalog/product_url model in formatUrlKey method, that is as follows:

  1. // convert non-alphanumeric characters - see below on the page
  2. $urlKey = Mage::helper('catalog/product_url')->format($str);
  3.  
  4. // replace remaining non-alphanumeric characters with dashes
  5. $urlKey = preg_replace('#[^0-9a-z]+#i', '-', $urlKey);
  6.  
  7. // make it lowercase
  8. $urlKey = strtolower($urlKey);
  9.  
  10. // trim dashes on the left and right
  11. $urlKey = trim($urlKey, '-');

Non-alphanumeric characters conversion rules

Non-alphanumeric characters conversion table is defined in Mage_Catalog module configuration file and can be overridden globally or per website/per store from within custom extensions config files or app/etc/local.xml.

  1. <config>
  2.   ...
  3.   <default>
  4.     ...
  5.     <url>
  6.       <convert>
  7.         ...
  8.         <char0228><from>ä</from><to>a</to></char0228>
  9.         ...
  10.         <char0246><from>ö</from><to>o</to></char0246>
  11.         ...
  12.         <char0252><from>ü</from><to>u</to></char0252>
  13.         ...
  14.       </convert>
  15.     </url>
  16.   </default>
  17. </config>

By default it convert umlauts to single characters (ä → a, ö → o, ü → u). Below is how it can be overriden in app/etc/local.xml to make to convert to 2-character sequence (ä → ae, ö → oe, ü → ue). Add the following code right before closing </config> tag :

  1.   <default>
  2.     <url>
  3.       <convert>
  4.         <char0228><from>ä</from><to>ae</to></char0228>
  5.         <char0246><from>ö</from><to>oe</to></char0246>
  6.         <char0252><from>ü</from><to>ue</to></char0252>
  7.       </convert>
  8.     </url>
  9.   </default>



 

Magento 2 GitHub Repository

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs