There is a question on stackoverflow, perhaps this is a better place to ask for:



You will need to create an entry in a layout.xml file to put an additional template in the head section of the page when you are on a category page (this would likely be in a catalog_Category_view block). You would also probably need a view file as well as a Block object to fetch the URL you want to use (technically you could put that in the view file, but having the block object is more "Magento").

Your layout.xml block would look something like this

    <reference name="head">
        <block type="canonical/canonical" name="head_url" as="head_url" template="ocaff/canonical/head.phtml" />

This block references a head.phtml file. That file would contain:

<link rel="canonical" href="<?php echo $this->getCanonicalUrl() ?>" />

This calls back to a block object that has a function called getCanonicalUrl(). In this function you will find and determine what you want the canonical to be. Most likely you want this to be the URL key, but you may have other logic in mind there.

  • this has nothing in common with my question. i want an export on cli – Kevin Horst Jul 1 '14 at 13:00
  • nice. there is always one person in the world who upvotes wrong answers. great work! – Kevin Horst Jul 1 '14 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.