This question already has an answer here:

i want to get product seo url from id

below is code i used to get url from id

$my_product = Mage::getModel('catalog/product')->load($id); 
$my_product_url = $my_product->getProductUrl();

but above code gives url like : catalog/product/view/id/226/s/slot-ring/category/58/

how to get seo url here like : /rings-10/start-with-setting.html

marked as duplicate by sv3n, Manoj Deswal, Prince Patel, Siarhey Uchukhlebau, Jai Oct 16 '17 at 12:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Try with following code:

$store = Mage::app()->getStore();
$path = Mage::getResourceModel('core/url_rewrite')
    ->getRequestPathByIdPath('product/456', $store);

$url = $store->getBaseUrl($store::URL_TYPE_WEB) . $path;

Just replace 456 with your product id.

  • for some product in multiple catgeory it does not give current category path in url pls help – user1799722 Jan 22 '15 at 13:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.