Magento Unicode URL Key for Products, Categories, CMS Pages

By default Magento does not support using UTF-8 characters as URL Keys, this tutorial show you how to make Magento accept non-english characters for Products, Categories and CMS pages.

This solution have been tested on Magento CE 1.9.1.0+:


1- Open \app\code\core\Mage\Core\Controller\Request\Http.php . At the setPathInfo method replace:

$requestUri = $this->getRequestUri();

with

$requestUri = urldecode($this->getRequestUri());

2- Open \app\code\core\Mage\Catalog\Model\Product\Url.php and at the formatUrlKey method replace:

$urlKey = preg_replace('#[^0-9a-z]+#i', '-', Mage::helper('catalog/product_url')->format($str));
$urlKey = strtolower($urlKey);

with

$urlKey = preg_replace('#()*!~-=+|\/[^0-9a-z%]+#i', '-', Mage::helper('catalog/product_url')->format($str));
$urlKey = str_replace(' ', '-', $urlKey);
$urlKey = mb_strtolower($urlKey,'UTF-8');

3- Open \app\code\core\Mage\Catalog\Model\Category.php and at the formatUrlKey method replace:

$urlKey = preg_replace('#[^0-9a-z]+#i', '-', $str);
$urlKey = strtolower($urlKey);

with

$urlKey = preg_replace('#()*!~-=+|\/[^0-9a-z%]+#i', '-', $str);
$urlKey = str_replace(' ', '-', $urlKey);
$urlKey = mb_strtolower($urlKey,'UTF-8');

4- Open \app\code\core\Mage\Cms\Model\Resource\Page.php and at the _beforeSave add this code after first foreach:

//shm: url key utf8
$str = $object->getData('identifier');
$identifier = preg_replace('#()*!~-=+|\/[^0-9a-z%]+#i', '-', $str);
$identifier = str_replace(' ', '-', $identifier);
$identifier = mb_strtolower($identifier,'UTF-8');
$identifier = trim($identifier, '-');
$object->setData('identifier', $identifier);
//shm: url key utf8

 Also at the same file find isValidPageIdentifier method and replace:

return preg_match('/^[a-z0-9][a-z0-9_\/-]+(\.[a-z0-9_-]+)?$/', $object->getData('identifier'));

with

return TRUE; 

5- Open \app\code\core\Mage\Adminhtml\Block\Cms\Page\Edit\Tab\Main.php and at the _prepareForm method replace:

$fieldset->addField('identifier', 'text', array(
  'name' => 'identifier',
  'label' => Mage::helper('cms')->__('URL Key'),
  'title' => Mage::helper('cms')->__('URL Key'),
  'required' => true,
  'class' => 'validate-identifier',
  'note' => Mage::helper('cms')->__('Relative to Website Base URL'),
  'disabled' => $isElementDisabled
));

with

$fieldset->addField('identifier', 'text', array(
  'name' => 'identifier',
  'label' => Mage::helper('cms')->__('URL Key'),
  'title' => Mage::helper('cms')->__('URL Key'),
  'required' => true,
  'class' => '',
  'note' => Mage::helper('cms')->__('Relative to Website Base URL'),
  'disabled' => $isElementDisabled
));
This is the code responsible for javascript validator at admin CMS pages, as default it only accepts english characters. This managed by adding validate-identifier class to related textfield. By commenting this line out admin can enter every character includes non-english characters. 
 

And don't forget to clear the cache. Also if you enabled compilatopn, Run Compilation Process.

Comments

Posted by Jose on
good ,
the changes works, but doesn´t work for second estore (alias) in multisotre. and the especial character á,é,í,ó,ú doesn´t works
Posted by dean on
this post helps me a lot, and save my money to buy extension, thanks a lot.
Posted by Alekos on
What files need to be changed in order to make it work on Magento 2?
Posted by saman on
Perfect,
it works for me on magento 1.9.2.4
Thanks a lot.
Posted by Raffael on
to be able to use hebrew letters or á,é,í,ó,ú - changes need to be made to:
$_convertTable in Mage/Catalog/Helper/Product/Url.php
Posted by ShowGaR on
Looking for the best app to watch free movies on your Android phone? Then your should check Showbox APK. This is the most famous app today that has a big library of shows and films. This app is also available for computer users. But your need to download it first to enjoy free films Showbox for PC Windows
Posted by HorazePsymn on
viagra coupon
http://xlviagracan.com - viagra for sale viagra from canada online inbox
viagra for sale - buy viagra online $0 99 pill overnight shipping
viagra testamonials