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


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

  • can you tell,what you want different store url ya site_url/page-fr.html??
    – Amit Bera
    Jul 21, 2014 at 6:55
  • i want to apply language switching and have 1900 such pages. Jul 21, 2014 at 6:58

2 Answers 2


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


created a helper in my custom module

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);
        return $coreUrl->getRequestPath();

and used it in languages.phtml

<?php if(count($this->getStores())>1): ?>
    $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();
                        echo $_lang->getCurrentUrl(false);
                ?>"<?php echo $_selected ?>><?php echo $this->escapeHtml($_lang->getName()) ?></option>
            <?php endforeach; ?>

<?php endif; ?>

-- Cheers


This is not possible out of the box.
CMS pages are in now way linked to each other.
So if you have 2 pages that for you mean the same thing but in different languages, for Magento they are 2 separate pages, one to be shown in one language and the other for the second language.

You will have to implement some kind of a general identifier to group pages with the same meaning.

or you can use url rewrites to say that page-fr is the french version of page-en. Then just look in the core_url_rewrites table to find the matches.

I've just released an extension that should make it easier for you to manage these url rewrites. You just have to enter the url key for each page in each language and it will generated the needed rewrites:
I know it still is a lot of work for almost 2k pages, but maybe you can use the code to read the values from a csv file. (this is the next feature I will try to implement).

  • I agree with this, the problem is i have 1900 such pages and want to apply language switching on them. And now i can't add url rewrite for all of them. Jul 21, 2014 at 6:57
  • 1
    damn, that's a lot of pages. I guess doing them manually is not an option. You will need some kind of script to group them all together. Unfortunately I don't have such a script. Just the ideas I mentioned in the answer.
    – Marius
    Jul 21, 2014 at 6:59
  • Thanks Marious, I was also thinking in same manner. I was thinking of making a helper and a function by which i get url key in another store from current page. Jul 21, 2014 at 7:06
  • @user2932242 See my edit to the answer. Maybe the extension helps you a little.
    – Marius
    Jul 25, 2014 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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