博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
关于router name 的url重写 --frontname rewrite frontname重写
阅读量:4201 次
发布时间:2019-05-26

本文共 1906 字,大约阅读时间需要 6 分钟。

对于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。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

转载地址:http://nncli.baihongyu.com/

你可能感兴趣的文章
易购考拉The first day
查看>>
易购考拉 The second day
查看>>
易购考拉 On the third day
查看>>
易购考拉 The fourth day
查看>>
易购考拉 The fifth day
查看>>
易购考拉 On the sixth day
查看>>
易购考拉 On the seventh day
查看>>
2020-11-15
查看>>
易购考拉15
查看>>
易购考拉day17
查看>>
征稿 | JIST 2019 Call for Workshop Proposals
查看>>
征稿 | JIST 2019 Call for Poster and Demo Papers
查看>>
论文浅尝 | 采用多层注意力机制的事件检测
查看>>
论文浅尝 | 基于知识图谱中图卷积神经网络的推荐系统
查看>>
会议 | CCKS 2019 全国知识图谱与语义计算大会在杭州隆重召开
查看>>
论文浅尝 | 利用图 Transformer 实现基于知识图谱的文本生成
查看>>
论文浅尝 | 面向自动问题生成的跨语言训练
查看>>
技术动态 | 知识图谱上的实体链接
查看>>
论文浅尝 | XQA:一个跨语言开放域问答数据集
查看>>
论文浅尝 | 将文本建模为关系图,用于联合实体和关系提取
查看>>