需要网址重写品牌列表

时间:2012-11-22 04:45:16

标签: magento

我想为SEO优化制作网址。

My URL is: supplements.html?manufacturer=166
I want URL like: supplements/manufacturer/scivation.html

(scivation是制造商的id 166和补充类别,制造商是属性)

非常感谢任何帮助。谢谢。

1 个答案:

答案 0 :(得分:0)

因为'补充'是一个类别(改变),所以在没有硬编码的情况下使用写入规则会更加困难。一种可能的解决方案是使用Mage::getModel('core/url_rewrite')example)为每个创建路由(使用此方法可能会遇到问题)

另一种解决方案是更改网址格式

  

/manufacturer/supplements/scivation.html

然后创建一个自定义模块

config.xml中

<global>
    <rewrite>
      <fancy_url>
            <from><![CDATA[/manufacturer\/(.*)/(.*)/]]></from>
            <to><![CDATA[manufacturer/index/processroute/manufacturername/$2/]]></to>
            <complete>1</complete>
       </fancy_url>
    <rewrite>
</global>
<frontend>
    <routers>
        <tagseo>
            <use>standard</use>
            <args>
                <frontName>customcategory</frontName>
            </args>
        </tagseo>
    </routers>

class MageIgniter_Manufacturer_IndexController extends Mage_Core_Controller_Front_Action
{
     public function processRoute(){
           print_r($requestUri = Mage::app()->getRequest()->getRequestUri()); //supplements/scivation.html
           print_r($this->getRequest()->getParam('manufacturername')); // scivation.html
           print_r($this->getRequest())
           // do you custom logic here base on about request path explode('/', trim($requestUri,'/'))

           //lookup the attribute_id from attribute name 
           //if attribute_id found then try 
           //$this->_forward(string $action, [string|null $controller = null], [string|null $module = null], [ $params = null])
           // to the catalog page
           // else  $this->_forward('defaultNoRoute');


     }
     ...

了解更多@

Simple URL Rewrite Using Magento xml

Magento Router Url - Need Hyphnated Path Name

Magento V1.7 Grid View - Add manufacturer attribute to view