Skip to content

Instantly share code, notes, and snippets.

@mkdizajn
Created January 26, 2014 10:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkdizajn/8630775 to your computer and use it in GitHub Desktop.
Save mkdizajn/8630775 to your computer and use it in GitHub Desktop.
magento switch websites snippet
<!-- BEGIN website switcher -->
<select id="website-changer" onChange="document.location=this.options[selectedIndex].value">
<?php
$websites = Mage::getModel('core/website')->getCollection();
foreach($websites as $website)
{
$default_store = $website->getDefaultStore();
$url_obj = new Mage_Core_Model_Url();
$default_store_path = $url_obj->getBaseUrl(array('_store'=> $default_store->getCode()));
?>
<option <?php if(strstr($this->helper('core/url')->getCurrentUrl(), $default_store_path)):?>selected="selected"< ?php endif; ?> value="< ?php echo $default_store_path ?>">< ?php echo $website->getName()?></option>
<?php
}
?>
</select>
<!-- END website switcher -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment