We have insert this code in the header.phtml to have on all web page:
<?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";
}
?>
It is working good, the only problem is it list 2 same URL and we have 2 different URL for all page/category/product
What appears:
<link rel="alternate" href="http://example.com/index.php/parts/battery.html" hreflang="fr_ca"/>
<link rel="alternate" href="http://example.com/index.php/parts/battery.html" hreflang="en_ca"/>
Whate we want to be displayed:
<link rel="alternate" href="http://example.com/index.php/pieces/batteries.html" hreflang="fr_ca"/>
<link rel="alternate" href="http://example.com/index.php/parts/battery.html" hreflang="en_ca"/>
How to do that?