Based on this answer, you can fetch baseurl from backend with his code:
Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
This won't work properly, if settings 'Add Store Code to Urls' is set to 'Yes' (details about that). In this case, it will add 'admin' into url.
I noticed that also
Mage::getModel('catalog/product')->load(1)->getProductUrl()
won't display proper url, it will add admin into url on fresh Magento installation.
Is that Magento bug? Is there any other proper way to get frontend base url from backend?
Best Answer
Try it like this:
For a product url do this:
$storeId
is the same as above.