1

I have created multistore in Magento. In admin panel i tried to get this multistore base url:

Below code i tried :

Mage::getStoreConfig("web/secure/base_url", 2);
Mage::getStoreConfig("web/secure/base_url", 5);
Mage::getStoreConfig("web/secure/base_url", 3);

Also i tried below code :

Mage::app()->getStore(2)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); 
Mage::app()->getStore(3)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); 
Mage::app()->getStore(5)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);

If i enterd this code in the site, the page was not loaded.

My Code in admin-panel(header.phtml) :

  <p class="super">
            <?php echo $this->__("Logged in as %s", $this->escapeHtml($this->getUser()->getUsername())) ?><span class="separator">|</span><?php echo $this->formatDate(null, 'full') ?><span class="separator">|</span><a href="http://golinks.magento.com/CE15" onclick="this.target='_blank'" class="go-try"><?php echo $this->__('Try Magento Go for Free') ?></a><span class="separator">|</span><a href="<?php echo $this->getLogoutLink() ?>" class="link-logout"><?php echo $this->__('Log Out') ?></a>
            &nbsp;&nbsp;&nbsp;
            <?php 
             if(Mage::helper('multistoreconfig')->multistore_config_enable()) {
                echo "<select class='no-changes' id='list_store' onchange=\"popWin(this.value,  '_blank')\"><option value=''>-- Select Store --</option>";
                foreach (Mage::app()->getWebsites() as $websiteid => $website) {
                    foreach ($website->getGroups() as $group) {
                        $stores = $group->getStores();
                        foreach ($stores as  $storeId => $store) {
                            $data = $this->checkMultiStoreConfigurInStoreId($storeId);
                            if( $data[0]['sub_directory'] || $storeId == 1) {
                                $option_url = Mage::getStoreConfig("web/secure/base_url", $storeId);
                                // $option_url = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
                                echo "<option value='". $option_url ."'>";
                                echo Mage::helper('multistoreconfig/data')->getStoreName($storeId);
                                echo "</option>";
                            }
                        }
                    }
                }
             }
             echo "</select>";
            ?>
    </p>

Any help would be appreciation.

1
  • I think your issue is in your code. The 'multistoreconfig' part imo. if you remove your whole code and just insert the test code below, I'm pretty sure you will get your store urls.
    – tecjam
    Commented Apr 8, 2015 at 15:13

1 Answer 1

0

Where did you place this code?

For me it works just fine in app/design/adminhtml/default/default/template/index/notifications.phtml

with the following code inserted at the end of the file:

<?php
echo    Mage::getStoreConfig("web/secure/base_url", 1);
echo '<br />';
echo    Mage::getStoreConfig("web/secure/base_url", 2);
?>
7
  • I have placed in this code "app/design/adminhtml/default/default/template/page/header.phtml". I am tring like store switch in admin panel.
    – VijayS91
    Commented Apr 8, 2015 at 14:13
  • This works for me also. Have you tried my code snippet? You may have some error in it if it prevents the entire page from loading.
    – tecjam
    Commented Apr 8, 2015 at 14:16
  • I have tried ur code in header.phtml.., Same error the page was not loaded.
    – VijayS91
    Commented Apr 8, 2015 at 14:22
  • That is strange. Does your backend work without your code? Can you paste the current content of your header.phtml?
    – tecjam
    Commented Apr 8, 2015 at 14:28
  • Yes working fine, with out above code. Also i have updated my question.
    – VijayS91
    Commented Apr 8, 2015 at 14:36

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.