【问题标题】:opencart: product url after homepage and after categoryopencart:主页和类别之后的产品网址
【发布时间】:2014-05-28 15:26:11
【问题描述】:

我正在使用 opencart 1.5.6。

主页(或类别以外的其他地方)上的产品链接到 /product,而当从类别页面点击时,它转到 /category/product。

这意味着谷歌认为有重复的内容,我不喜欢这样我该如何解决这个问题(所以网址总是 /categorie(/subcat)/product?

我希望所有其他页面也有一个干净的 seo url,但是当我安装以下扩展时,什么也没发生:

www.opencart.com/index.php?route=extension/extension/info&extension_id=15557&filter_search=seo%20url&filter_license=0&sort=e.downloaded&order=DESC&page=3 www.opencart.com/index.php?route=extension/extension/info&extension_id=15516

网站网址: http://publiekgeheim.com

【问题讨论】:

    标签: url seo opencart clean-urls


    【解决方案1】:

    您不必担心重复的内容。正如我所看到的,您的产品的<head> 中有“规范”链接标签,所以您没问题。这个标签告诉搜索引擎哪个 url 是“正确的”,而其他的只是由插件、分类等产生的。所以没有重复的内容。

    在 opencart 中,除非您想编写代码并制作场景并更改您的工作流程,否则生成规范标签的最佳方式就是现在所做的。也就是说,www.example.com/product。原因是opencart产生诸如http://publiekgeheim.com/lingerie/Esprit/Esprit-Feel-Sexy-String之类的url的方式,其中包含了类别路径,确实是不可靠的。例如,以下网址http://publiekgeheim.com/stackoverflow/Goerge/wtf/Esprit-Feel-Sexy-String will also lead you to the product page

    如果您仍想按照自己的方式进行操作,则必须在 catalog/product/product.php 中更改此行:

    $this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical');
    

    这就是痛苦的开始。您可以使用catalog/model/catalog/product.php中的getCategories方法,获取商品所属的分类。但是您要显示哪一个?如果您只为您的产品分配一个类别,那么您很幸运。但如果不是呢?在我的商店中,我什至经常将产品分配到两个基本相同但属于不同父类别的类别中,以帮助用户更轻松地找到产品(因为 opencart 不允许将链接(到类别)作为菜单顶部菜单中的项目)。如果我想遵循您的方法,我将需要使用一些扩展程序来允许我将链接放在顶部菜单中,但这些扩展程序会在我的站点地图中创建空的、重复的类别,或者使用一些可以完全替换默认顶部菜单的大型菜单。然后就会出现新的问题。因此,您会看到,根据您的用例,它会变得越来越复杂。

    即使您设法克服了这一点(例如,通过选择随机或返回的第一个类别,或者从现在开始仅将产品分配给一个类别),您将如何在其中找到父类别为了在 url 中显示完整路径? opencart 中没有这样的方法,并且编码这真的很难看,并且会向产品页面添加至少 3 个 db 查询(我试图计算需要多少个 db 查询才能生成默认的 opencart 页面,我至少数了一下10).

    因此,总而言之,为了避免出现棘手的情况,请坚持使用默认规范,除非您针对如何上传和显示产品以及一些巧妙的代码制定严格的政策。

    这些扩展应该可以工作。检查您的 vqmod 错误和兼容性。

    【讨论】:

      【解决方案2】:

      我已经解决这个问题几天了,终于弄明白了。 1.5.6.4 从主页和相关产品链接时,类别/产品而不是/产品。

      1.在 /catalog/controller/module/showintabs.php

      之后:

      if ($this->config->get('config_review_status')) {
                      $rating = $result['rating'];
                  } else {
                      $rating = false;
                  }
      

      添加:

      $categories = $this->model_catalog_product->getCategories($result['product_id']);
                  if(isset($categories[0]) && !empty($categories[0])){
                      $path = $categories[0]['category_id'];
                  }else{
                      $path = '';
                  }
      

      AND in $products[] = 正下方的数组

      更改: 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']),

      'href' => $this->url->link('product/product', 'path=' . $path . '&product_id=' . $result['product_id']),

      2。在 /catalog/controller/product/product.php

      之后 if ($this->config->get('config_review_status')) { $rating = (int)$result['rating']; } 别的 { $评级=假; }

      添加 $categories = $this->model_catalog_product->getCategories($result['product_id']); if(isset($categories[0]) && !empty($categories[0])){ $path = $categories[0]['category_id']; }别的{ $路径 = ''; }

      AND in $this->data['products'][] = array( 正下方

      更改: 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']),

      'href' => $this->url->link('product/product', 'path=' . $path . '&product_id=' . $result['product_id']),

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-04-06
        • 2015-05-02
        • 1970-01-01
        • 2012-11-26
        • 2017-04-30
        相关资源
        最近更新 更多