zoukankan      html  css  js  c++  java
  • Magento多级分类URL去掉父目录

    在Magento模板开发中,有时候需要将多级分类的url简化,Magento的URL默认是显示多级分类的

    http://www.a.com/分类1/分类2/分类3

    现在需要简化为:

    分类2的URL为:http://www.a.com/分类2

    分类3的URL为:http://www.a.com/分类3

    具体修改方法如下:

    打开app/code/core/Mage/Catalog/Model/Url.php这个php文件,找到

    if (null === $parentPath) {
    $parentPath = $this->getResource()->getCategoryParentPath($category);
    }
    elseif ($parentPath == '/') {
    $parentPath = '';
    }

    把上面的代码修改为:

    //if (null === $parentPath) {
    //$parentPath = $this->getResource()->getCategoryParentPath($category);
    //}
    //elseif ($parentPath == '/') {
    $parentPath = '';
    //}

    其实就是把这段代码屏蔽掉了。
    其中

    $parentPath = $this->getResource()->getCategoryParentPath($category);

    是获取分类的父级分类,下面将父级分类设置为空则在生成的URL中屏蔽掉父级
    仔细观察core_url_rewrite表里面的数据 就会发现

  • 相关阅读:
    Linux 磁盘管理
    Linux 特殊权限及if语句
    Linux find命令
    MySQL索引知识介绍
    MySQL库表设计小技巧
    教你用SQL实现统计排名
    Truncate用法详解
    utf8字符集下的比较规则
    关于Aborted connection告警日志的分析
    MySQL DDL详情揭露
  • 原文地址:https://www.cnblogs.com/liuxgnu/p/3535414.html
Copyright © 2011-2022 走看看