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


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.