Url friendly string

If you need to transform some string to url-friendly string in Magento you just need to call method “formatUrlKey” from Mage_Catalog_Model_Product_Url class

<?php
    $urlKey = Mage::getModel('catalog/product_url')->formatUrlKey($string);
?>

You can use this new variable $urlKey as url_key field for product or for some other attributes (for example: slug, sku, code etc)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.