magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Category auto-generate URL problem

Open U12358 opened this issue 13 years ago • 2 comments

I see this problem from version 1.4.0.2. (This problem is present at least 5 years.)

When creating new Category and input Name with non-English symbols and save then system auto-generate URL like 'doed-n-d-d-d-d-n-d-d-n-d-d-d-n-d-n.html' instead of 'moja-novaja-kategorija.html'

For Product auto-generating URL works fine - 'moja-novaja-kategorija.html'.

I fixing this bug in class Mage_Catalog_Model_Category by changing formatUrlKey function - calling formatUrlKey from Mage_Catalog_Model_Product_Url.

public function formatUrlKey($str)
{
    return Mage::getSingleton('catalog/product_url')->formatUrlKey($str);
}

instead of native function

public function formatUrlKey($str)
{
    $str = Mage::helper('Mage_Core_Helper_Data')->removeAccents($str);
    $urlKey = preg_replace('#[^0-9a-z]+#i', '-', $str);
    $urlKey = strtolower($urlKey);
    $urlKey = trim($urlKey, '-');
    return $urlKey;
}

U12358 avatar Jun 15 '13 12:06 U12358

Hello. Could you please provide a pull request and tests for this change?

magento-team avatar Jun 18 '13 15:06 magento-team

Yes i can. I will do it a bit later.

U12358 avatar Jun 19 '13 06:06 U12358