1

I have a Magento 1.8 multi store installation. Each store is installed in a sub folder (www.mydomain.com/, www.mydomain.com/paris/, www.mydomain.com/nimes/) and contains the same products with different stock values.

With such an install, I have a lot of duplicate content: www.mydomain.com/product1.html and www.mydomain.com/paris/product1.html are showing duplicate content.

That's why I'd like to define a store as canonical and have pages from other stores point to the corresponding page on the main store.

Any suggestion on how to implement this?

1 Answer 1

0

I achieved my goal by using an observer to modify the canonical links for category and product pages of stores in subfolders:

class Fkoessler_Canonical_Model_Observer
{

  public function coreBlockAbstractToHtmlBefore($observer)
    {
        $block = $observer->getBlock();

        if ($block instanceof Mage_Page_Block_Html_Head) {

            $url = Mage::helper('core/url')->getCurrentUrl();
            if (Mage::registry('current_product')) {
                $url = Mage::registry('current_product')->getProductUrl();
            } else if (Mage::registry('current_category')) {
                $url = Mage::registry('current_category')->getUrl();
            }
            $block->removeItem('link_rel', $url);

            $url = str_replace('/paris', '', $url);
            $url = str_replace('/niort', '', $url);
            $url = str_replace('/nimes', '', $url);

            $block->addLinkRel('canonical', $url);
        }
    }
}

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .