首页 文章

opencart:主页后和类别后的产品网址

提问于
浏览
0

我使用的是opencart 1.5.6 .

主页(或其他类别的产品)上的产品链接到/产品,而当它从类别页面中进行了go /类别/产品 .

这意味着谷歌认为有重复的内容,我不喜欢这样,所以如何解决这个问题(所以url是allways / 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

2 回答

  • 2

    您不必担心重复的内容 . 我可以看到你的产品的 <head> 中有"canonical"链接标签,所以你没问题 . 这个标签告诉搜索引擎哪个url是"correct",其他的只是插件,分类等产生的 . 所以没有重复的内容 .

    在opencart中,除非您想编写和制作场景并更改工作流,否则生成规范标记的最佳方法就像现在一样 . 那就是 www.example.com/product . 原因是opencart产生的方式如 http://publiekgeheim.com/lingerie/Esprit/Esprit-Feel-Sexy-String ,其中包含类别路径,实际上是不可靠的 . 例如,以下网址 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不允许将链接(到类别)作为菜单顶部菜单中的项目) . 如果我想按照你的方法,我需要使用一些扩展,允许我在顶部菜单中放置链接,但在我的站点 Map 中创建空的,重复的类别或使用一些完全取代默认顶级菜单的大型菜单 . 然后会出现新的问题 . 因此,您会发现根据您的使用情况,它变得越来越复杂 .

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

    总而言之,除非你对如何上传和展示产品以及一些聪明的代码提出严格的政策,否则要避免让棘手的情况坚持默认规范 .

    这些扩展应该有效 . 检查您的vqmod错误和兼容性 .

  • 0

    我已经和这个问题坐了好几天了,终于弄明白了 . 1.5.6.4从HOME和相关产品链接时的类别/产品而不是/产品 .

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

    AFTER:

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

    ADD:

    $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[] = array right below it

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

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

    2. In /catalog/controller/product/product.php

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

    ADD $ 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 $this->data['products'][] = array( right below it

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

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

相关问题