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

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

问题描述

我们正在对我们的 Magento 店面进行一些 SEO 优化,我需要一些关于更改类别 URL 的最佳方法的建议.我们的 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 个左右的类别进行这些网址更改.

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 的内置重写模块)来完成其中的一部分,但是解决这个问题的最佳方法是什么?我的缺点之一看到使用 301s 是主导航将继续在其链接中包含长的子类别 url.我应该考虑做一个允许我们为类别指定确切 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 重写管理器的示例.

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

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

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