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

例如:http://www.360magento.com/分类1/分类2/分类3

现在需要简化为:

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

分类3的URL为:http://www.360magento.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中屏蔽掉父级

360magento提供专业的基于magento系统的电商网站开发服务,如有需求或相关咨询,请与我们联系