URL Key characters conversion

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

Product URL Key

Product URL Key is prepared in catalog/product_url model in formatUrlKey method, in the following sequence:

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