This question already has an answer here:

is it possible to quickly get a products URL from it's id? We're having an issue where the product URLs of configured (simple child) products are overlapping. By this I mean when 2+ configurations (simple children) of a configurable product are added to the cart the URLs always divert to the first option

marked as duplicate by sv3n, Piyush, Manoj Deswal, Jai, Siarhey Uchukhlebau Jan 15 '18 at 5:48

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.

  • A sidenote: Magento will create a URL for not visible simple products of configurables: dnd.fr/2012/09/… – B00MER Apr 18 '15 at 3:59

You can get product url by loading catalog product model object using product id

$product = Mage::getModel('catalog/product')

$productUrl = $product->getProductUrl();

Change $productId with your product ID below. You can also specify different store (or store ID will also work) in the 3rd argument.

$urlKey = Mage::getResourceSingleton('catalog/product')
  ->getAttributeRawValue($productId, 'url_key', Mage::app()->getStore());
$productUrl = Mage::getBaseUrl() . $urlKey;

This works for me.

$url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB).$_product->getUrlKey();

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