Magento 1.9 Product URL – Get Product Frontend URL in Admin

magento-1.9producturl

I am using below code to get Product frontend URL in admin but it's throwing 404 error.

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

Can anyone tell me how to get product frontend URL in admin. I want to get rewrite URL so that if I click on link then it will redirect to product view page in frontend.

Best Answer

$storeId = 1;
$product = Mage::getModel('catalog/product')->setStoreId()->load($productId);
$url = $product->getProductUrl();

just replace 1 with your store id.

Related Topic