dongzhun1857 2014-01-24 17:37
浏览 70
已采纳

Magento SEO链接

My client knows a little about SEO , but I don't. According to him , our urls are not fine because they are duplicated. Here are the examples of what is happening:   Our website sells cookware, so we have the following categories, for example: Cast iron and grates. The grates category is a subcategory from cast iron.   Knowing that, we have a square grate and it is at the home page. Accessing the product from the home page, the link is something like "/square-grate.html".   If I enable the category link (going into settings> Catalog> Insert Category of Products in URLs ), I get the following links: "/square-grate.html" - by accessing from home page "cast-iron/square-grate.html" - by accessing from the category page cast iron "cast-iron/grates/square-grate.html" - by accessing the cast iron category , then the subcategory grates   Just what my client need is that all the above examples urls are the "/cast-iron/square-grate.html" does someone has any hint how can I do that?

Maybe changing .htacess or some php script, but I don't have any idea how to do that.

  • 写回答

2条回答 默认 最新

  • doumang20060820 2014-01-27 02:39
    关注

    Using Magento's canonical feature will be the easiest way to resolve this problem. The only downfall is it won't include the category names and may miss out on additional keywords in the URL. Developing or purchasing a module is the next best way if you have the programming skills or budget to do so. If you're on a limited budget, you may get able to get away without spending any money if you're comfortable doing some modifications and data entry/database import.

    I'm not a very good programmer but I got around this adding a new attribute, say canonical_category. Before Magento 1.8, I was able to override the $categoryid with a new value based on the category IDs. For instance, whatever I wanted to set as the canonical link, I would just enter a number in the new attribute field and it would generate a link with that category.

    Magento 1.8 is slightly different, as they looked like they updated that section. Unfortunately I can't look at it now and tell you how to get the same functionality, but I quickly went through the new code and put together a workaround in case it may help you.

    The file that needs to be modified is /app/code/core/Mage/Catalog/Model/Product/Url.php. On line 267 we'll find the code that handles the canonical link, function _getProductUrl. Basically we're going to use the canonical_category value if available and just fallback on the original code if nothing is entered.

    So we'll change this line of code:

    if (!empty($requestPath)) {
        return $this->getUrlInstance()->getDirectUrl($requestPath, $routeParams);
    }
    

    to

    if (!empty($requestPath)) {         
            if($product->getCanonicalCategory()) {
                return $this->getUrlInstance()->getDirectUrl($product->getCanonicalCategory());
            } else {
                return $this->getUrlInstance()->getDirectUrl($requestPath, $routeParams);
            }
        }
    

    Just to be clear, all this will do is let you specify what you want your canonical link to be, in your case you want to include the category name. Your links to the product page will still appear to be the same (square-grate.html, /cast-iron/square-grate.html) but from what I understand the search engines will still treat this as the same page as long as a canonical link is specified. This should resolve the SEO issue but now there is more work if you want a specific link to be used. I can tell you any method that is not done dynamically is not the best way, but it will work and you can update/generate links easily via spreadsheet and database import. You can also just use it on products that need to include the additional [category] keywords. Note that the URL that is entered for the attribute should be relative (ie "cast-iron/square-grate.html"). Hopefully this helps.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图