现在的位置: 首页 > 综合 > 正文

Magento中如何去掉子分类的url地址中带有父分类的url key?

2013年09月10日 ⁄ 综合 ⁄ 共 631字 ⁄ 字号 评论关闭

     大家也许发现,用magento系统开发的商城中,子目录的url地址默认会带上一级目录的url key,如果一个名称为fatherCategory父目录的url地址是 http://ttmei8.taobao.com/fatherCategory/,那它的名称为subcategory的子目录的url地址会显示为 http://ttmei8.taobao.com/fatherCategory/subcategory/。如果要去掉子目录中带的父目录的url key,修改下列代码来实现。

    打开app/code/core/Mage/Catalog/Model/Url.php这个php文件,转到第632行,将这段代码修改

   if (null === $parentPath) {

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

  }

   elseif ($parentPath == '/') {

  $parentPath = '';

   }

  为

   

   //if (null === $parentPath) {

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

  //}

   //elseif ($parentPath == '/') {

  $parentPath = ''; //('这一句不用注释')

   //}

  然后保存并上传。

抱歉!评论已关闭.