【发布时间】:2016-08-11 03:56:14
【问题描述】:
Magento 版本是 1.9.2.3。
我尝试了以下对我不起作用的解决方案。
步骤 1:转到 app/code/core/Mage/Catalog/Model/Url.php 将此文件复制到 app/code/local/Mage/Catalog/Model/Url.php 因为它是核心 Magento 文件,这样我们必须将该文件复制到 app/code/local。
第 2 步:现在在 Magento 版本的第 698 行附近搜索 getCategoryRequestPath($category, $parentPath)。 1.9.1.0
第 3 步:在第 717 行附近搜索 if (null === $parentPath) 并将该行注释如下:
/* if (null === $parentPath) {
$parentPath = $this->getResource()->getCategoryParentPath($category);
}
elseif ($parentPath == '/'){*/
$parentPath = ''; //DO NOT Comment this line
//}
第 4 步:现在转到 Magento 管理员并清除缓存系统->缓存管理和重新索引系统->索引管理数据。
第 5 步:刷新浏览器缓存并再次导航,现在您将在 Url 中看到子类别,而不是父类别,就像 http://www.abcxyz.com/test-category-level-1-3.html - 查看更多信息:http://www.expertwebadvisor.com/remove-parent-category-path-from-sub-category-url-in-magento/#sthash.cy3HvxwW.dpuf
我也试过这个对我不起作用的解决方案。
假设要从url中去掉父类路径如Url-> www.domain.com/cat1/cat2 到 www.domain.com/cat2
用法:
Go to the Magento Admin Panel -> System -> Configuration -> Catalog -> Seo Options
Select yes or no from "Use Parent Category Path for Category URLs"
Refresh category url index.
选项 YES => www.domain.com/cat1/cat2
选项 NO => www.domain.com/cat2
如果您有其他解决方案,请帮助我
【问题讨论】:
标签: magento url-rewriting categories