Magento:重写深层嵌套的类别页面 [英] Magento: Rewrites for deeply nested category pages

查看:69
本文介绍了Magento:重写深层嵌套的类别页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在Magento商店中进行一些SEO优化,我需要一些有关更改类别网址的最佳方法的建议.我们的SEO承包商希望更改以下网址:

We are doing some SEO optimizations on our Magento store front and I need some advice on the best way to change category urls. Our SEO contractors want to change a bunch of urls from:

/base-cat/sub-cat1/sub-cat2.html 

/seo-friendly-cat2.html.

我们有一堆嵌套类别(5个顶级类别和一堆子类别,最多4个层次).由于这有助于我们的客户在主导航中向下钻取,因此我们不确定是否要更改类别层次结构.但是我们可能会在100个左右的类别中进行这些url更改.

We have a bunch of nested categories (5 top-level and a bunch of sub categories up to 4 levels deep). Since this helps our customers drill down through the main navigation, we aren't sure if we want to change the category hierarchy. But we might be doing these url changes on 100 categories or so.

我知道我们可以使用301重写(使用.htaccess或Magento的内置重写模块)来完成部分操作,但是解决此问题的最佳方法是什么?看到使用301是主导航将继续在其链接中包含长的子类别网址.我应该看看做一个自定义模块,该模块允许我们为类别指定确切的url(而不是特定于层次结构的url令牌)吗?您有什么建议?

I know we can do part of this with using 301 rewrites (using .htaccess or Magento's built-in rewrite module), but what is the best way to approach this? One of the drawbacks I see to using 301s is that the main navigation will continue to have the long, sub category url in it's link. Should I look at doing a custom module that allows us to specify an exact url for categories (rather than a url token specific to the hierarchy)? What is your advice?

推荐答案

您很有可能想要编写一个脚本来为您执行此操作,并将其保留在Magento的URL管理中,而不是一些难以处理的清单.htaccess等文件中的重写/重定向.

More than likely you're going to want to write a script to do this for you and keep it within Magento's URL Management instead of some long un-manageable list of rewrites/redirects in .htaccess or such.

我认为您最大的问题是存在相同文件名的任何冲突以及您将如何处理此类冲突.

Your biggest issue I would think would be any collisions where the same filename exists and how you would want to handle such.

Mage::getModel('core/url_rewrite')
->setIsSystem(0)
->setStoreId($storeId)   
->setOptions('RP')  
->setIdPath('index.php?cat=c' . $categoryId . '_' . $this->strip($data['name']) . '.html')
->setTargetPath($categoryModel->getUrlPath() . '.html')
->setRequestPath('index.php?cat=c' . $categoryId . '_' . $this->strip($data['name']) . '.html')
->save();

这只是如何在Magento的URL Rewrite Manager中添加重写的示例.

This is just an example of how to add rewrite's into Magento's URL Rewrite Manager.

这篇关于Magento:重写深层嵌套的类别页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆