I am using the following code to generate the hreflang on my website:
<?php
$groupId = Mage::app()->getStore()->getGroupId();
$collection = Mage::getModel('core/store')->getCollection()->addFieldToFilter('group_id', $groupId);
foreach ($collection as $store) {
echo '<link rel="alternate" href="' . preg_replace('/\?.*/', '', $store->getCurrentUrl()) . '" hreflang="' . $store->getCode() . '"/>' . "\n";
}
?>
This gives me the links exactly the way I want them but with the exception of 'default' store that appears as www.example.com/default/.
I would like to replace 'default' with 'en'. Is there a way to do it? I tried looking for the code but can't find it any where as most developers tend to use getWebsite instead of getstore. Would really appreciate if someone can help with the appropriate code in php that can be pasted in head.phtml.