Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'app/Mage.php';
- Mage::app();
- $langStores = array();
- $stores = Mage::app()->getStores();
- $currentUrl = Mage::helper('core/url')->getCurrentUrl();
- $currentStore = Mage::app()->getStore();
- $urlType = Mage_Core_Model_Store::URL_TYPE_LINK;
- $xmlLocalPath = Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE;
- $isCurrentlySecure = $currentStore->isCurrentlySecure();
- $currentBaseUrl = $currentStore->getBaseUrl($urlType, $isCurrentlySecure);
- foreach ($stores as $store) {
- if ($store->getIsActive() && $store->getId() != $currentStore->getId()) {
- $lang = Mage::getStoreConfig($xmlLocalPath, $store->getId());
- $lang = strtolower(str_replace("_", '-', $lang));
- $langStores[$lang] = $store->getBaseUrl($urlType, $isCurrentlySecure);
- }
- }
- $currentUri = str_replace($currentBaseUrl, '', $currentUrl);
- foreach ($langStores as $lang => $url) {
- echo '<link rel="alternate" hreflang="' . $lang . '" href="' . $url . $currentUri . '" />' . PHP_EOL;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement