关于router name 的url重写 --frontname rewrite frontname重写!

对于tag

也就是在url中有tag的url,希望改成wholesale等其他方式,

1

参看blog插件方式:

在etc/config.xml中添加事件:

<events>

 <sitemap_add_xml_block_to_the_end>
                <observers>
                    <add_blog_section>
                        <type>singleton</type>
                        <class>blog/observer</class>
                        <method>addBlogSection</method>
                    </add_blog_section>
                </observers>
            </sitemap_add_xml_block_to_the_end>
        </events>

 

然后通过方法:

 public function addBlogSection($observer)
    {
            $sitemapObject = $observer->getSitemapObject();
            if (!($sitemapObject instanceof Mage_Sitemap_Model_Sitemap))
                throw new Exception(Mage::helper('blog')->__('Error during generation sitemap'));
           
            $storeId = $sitemapObject->getStoreId();
            $date    = Mage::getSingleton('core/date')->gmtDate('Y-m-d');
            $baseUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
            /**
             * Generate blog pages sitemap
             */
            $changefreq = (string)Mage::getStoreConfig('sitemap/blog/changefreq');
            $priority   = (string)Mage::getStoreConfig('sitemap/blog/priority');
            $collection = Mage::getModel('blog/blog')->getCollection()->addStoreFilter($storeId);
            Mage::getSingleton('blog/status')->addEnabledFilterToCollection($collection);
            $route = Mage::getStoreConfig('blog/blog/route');
            if ($route == "") {
               $route = "blog";
            }
            foreach ($collection as $item) {
                $xml = sprintf('<url><loc>%s</loc><lastmod>%s</lastmod><changefreq>%s</changefreq><priority>%.1f</priority></url>',
                    htmlspecialchars($baseUrl . $route . '/' . $item->getIdentifier()),
                    $date,
                    $changefreq,
                    $priority
                );

                $sitemapObject->sitemapFileAddLine($xml);
            }
            unset($collection);
    }

来实现,这种方式很灵活,是可以在后台定义router的,下面来看第二种

 

 

2

这种方式比较简单了,具体为新建一个module,然后routername为你要修改的名字,然后

事件

 <controller_front_init_routers>

进行处理判断,如果符合条件,执行下面语句:

 

 

 

$request->setModuleName('tag')
                    ->setControllerName('product')
                    ->setActionName('list');

 

然后就转移到相应的module了,但是url是不会变了

如果这个module的router为wholesale,那么,url不会跳转,执行的为tag/product/list的代码:

3

这是一种最笨的办法了,将tag改,改他的源代码,极力不推荐!!!

 

magneto。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值