Chinaunix首页 | 论坛 | 博客
  • 博客访问: 268475
  • 博文数量: 59
  • 博客积分: 1368
  • 博客等级: 中尉
  • 技术积分: 1071
  • 用 户 组: 普通用户
  • 注册时间: 2012-02-02 06:06
文章分类

全部博文(59)

文章存档

2012年(59)

我的朋友

分类: 系统运维

2012-03-04 02:17:29

Magento提供了灵活的URL结构,用户可以根据自己的需求对产品和分类的URL进行设置。

1 URL的后缀
产品和分类的URL的后缀默认为空,如果想显示为.html的格式,可以在后台设置:System>Configuration>CATALOG>Catalog>Search Engine Optimizations,将Product URL Suffix和Category URL Suffix的值都设置为.html

2 产品的URL
产品的URL在Magento中默认是带分类路径的,比如 electronics/cell-phones/nokia-2610-phone.html 如果不想URL中加入分类信息,只要 nokia-2610-phone.html 这样的格式,可以将Use Categories Path for Product URLs的值设置为No

3 分类的URL
分类的URL在Magento中默认是带上级分类的,比如 electronics/cell-phones.html 如果不想URL中加入上级分类信息,只要 cell-phones.html 这样的格式,可以做以下修改:
打开/app/code/core/Mage/Catalog/Model/Url.php
在 generatePath() 函数中将
  1. if (null === $parentPath) {
  2.     $parentPath = $this->getResource()->getCategoryParentPath($category);
  3. }
  4. elseif ($parentPath == '/') {
  5.     $parentPath = '';
  6. }
修改为
  1. #if (null === $parentPath) {
  2.     #$parentPath = $this->getResource()->getCategoryParentPath($category);
  3. #}
  4. #elseif ($parentPath == '/') {
  5.     $parentPath = '';
  6. #}
使用phpmyadmin清空表core_url_rewrite并刷新Index和缓存。
阅读(4077) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~