且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Magento:重写深度嵌套的类别页面

更新时间:2023-11-30 14:47:10

您很可能希望编写一个脚本来为您执行此操作,并将其保存在 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.