Magento – get other store url on same page

multistoreurl

I have many pages which has different url key for different stores.

Can I get current URL on basis of store ID. function I am using right now is getCurrentUrl().

I mean let suppose i have two stores en and fr. Now I have a page with 2 url

(page-en.html, page-fr.html).

Right now let suppose i am at

page-en.html 

so if I write something like getCurrentURL(fr) then I should get

site_url/page-fr.html.

Best Answer

Thanks a lot for your responses. I used approach given here

http://inchoo.net/ecommerce/magento/get-rewritten-product-url-in-a-different-store/

created a helper in my custom module

<?php
class Custom_Import_Helper_Data extends Mage_Core_Helper_Abstract
{
    public function rewrittenProductUrl($productId, $categoryId, $storeId)
    {
        $coreUrl = Mage::getModel('core/url_rewrite');
        $idPath = sprintf('product/%d', $productId);
        if ($categoryId) {
            $idPath = sprintf('%s/%d', $idPath, $categoryId);
        }
        $coreUrl->setStoreId($storeId);
        $coreUrl->loadByIdPath($idPath);
        return $coreUrl->getRequestPath();
    }
}

and used it in languages.phtml

<?php if(count($this->getStores())>1): ?>
    <?php
    $helper = Mage::helper('Import');
    $prod = Mage::registry('current_product');
    $categ = Mage::registry('current_category');
    $categId = $categ ? $categ->getId() : null;
    ?>
    <div class="form-language">
        <label for="select-language"><?php echo $this->__('Your Language:') ?></label>
        <select id="select-language" title="<?php echo $this->__('Your Language') ?>" onchange="window.location.href=this.value">
            <?php foreach ($this->getStores() as $_lang): ?>
                <?php $_selected = ($_lang->getId() == $this->getCurrentStoreId()) ? ' selected="selected"' : '' ?>
                <option value="<?php
                    if($prod) {
                        echo $_lang->getBaseUrl() . $helper->rewrittenProductUrl($prod->getId(), $categId, $_lang->getId()) . '?___store=' . $_lang->getCode();
                    }else{
                        echo $_lang->getCurrentUrl(false);
                    }
                ?>"<?php echo $_selected ?>><?php echo $this->escapeHtml($_lang->getName()) ?></option>
            <?php endforeach; ?>
        </select>
    </div>

<?php endif; ?>

-- Cheers