0
votes

We have a multistore setup in Magento - well, a two-store setup:

  • English for USD transactions and,
  • English for CAD transactions

The "en" store goes with the default URL — i.e. domain.com/ The "en-ca" store is setup as a subfolder — i.e. domain.com/ca/

The product/category URLs are all the same, they're merely appended at the end of the above store URLs.

We need to add the following tags:

<link rel="alternate" hreflang="en" href="http://domain.com/" />
<link rel="alternate" hreflang="en-ca" href="http://domain.com/ca/" />

where the product/category urls are appended to the store domains in the href tag.

For a Product URL: domain.com/product-name.html the above tags should become:

<link rel="alternate" hreflang="en" href="http://domain.com/product-name.html" />
<link rel="alternate" hreflang="en-ca" href="http://domain.com/ca/product-name.html" />

For a Category url: domain.com/category1/subcategory2/ the above tags should become:

<link rel="alternate" hreflang="en" href="http://domain.com/category1/subcategory2/" />
<link rel="alternate" hreflang="en-ca" href="http://domain.com/ca/category1/subcategory2/" />

What needs to be added to the template header .phtml files in order to get these output correctly for each product or category page, please?

1

1 Answers

1
votes

Try putting this in your header file:

<?php $url = str_replace(".com",".com/ca" , Mage::helper('core/url')->getCurrentUrl()); ?>
<link href="<?php echo $url; ?>" hreflang="en-CA" rel="alternate" />

<?php $url = str_replace(".com/ca",".com" , Mage::helper('core/url')->getCurrentUrl()); ?>
<link href="<?php echo $url; ?>" hreflang="en" rel="alternate" />

It will generate the hreflang URL for you.