X
X
xuxubla2016-03-09 09:49:23
Search Engine Optimization
xuxubla, 2016-03-09 09:49:23

How to make a canonical link for the full path to a product in Magento?

A lot of discussions, but I did not find the answer to my question.
The same product is available at the following addresses:
1) domain/category/subcategory/product-page
2) domain/category/product-age
3) domain/product-
page canonical link #3. But I need link 1 to be canonical.
Or do it without canonicals at all and put 404 on all pages except the first one.
If there is no specific solution, then at least tell me, in the direction of which modules / functions inside Magento should I look for a solution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly, 2016-03-09
@ZAnatoly

The link for the canonical tag is pulled from the getUrl function, so it is always different, because it depends on how the user got to this page.
I can advise the following:
1) bring all links to the same form, regardless of the path to the page. To do this, use another function: getCurrentUrl.
2) Disable the generation of the canonical link for the catalog in the settings in SYSTEM> CONFIG> Catalog> Search engine optimization (SEO) --- Use Canonical Link Meta Tag For Categories (set to NO).
3) generate a canonical link through the layout file app\design\frontend\PACKAGE\THEME\layout\local.xml
For example, by default, for all pages using the getCurrentUrl function:

<default>
    <reference name="head">
            <action method="addLinkRel">
        <rel>canonical</rel>
        <href helper="core/url/getCurrentUrl"/>
      </action>
        </reference>
    </default>

3.1.) if desired and with sufficient knowledge, "correct" this function.
3.2.) if you want to generate a canonical in the local.xml file for specific pages, and not by default, for example, for catalog pages with pagination, use
<catalog_category_layered></catalog_category_layered>
etc.
4) check modules for loading their canonical links.
I hope that helped.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question