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

本文共 1953 字,大约阅读时间需要 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://jncli.baihongyu.com/

你可能感兴趣的文章
论文浅尝 | S3QLRDF: 用于大规模RDF数据分布式SPARQL查询的关系分割架构
查看>>
论文浅尝 - ICLR2021 | BERTology 遇上生物学:在蛋白质语言模型中解释注意力
查看>>
论文浅尝 | BoxE:一种基于Box的知识图谱表示学习模型
查看>>
论文小综 | Attention in Graph Neural Networks
查看>>
技术动态 | 不确定性知识图谱的表示和推理
查看>>
论文浅尝 - ECIR2021 | 两种实体对齐方法的严格评估
查看>>
论文浅尝 | 用于嵌套命名实体识别的二部平面图网络(BiFlaG)
查看>>
会议交流 | 智能风控技术峰会(请关注图分析相关论坛)
查看>>
开源开放 | 欢迎选修浙江大学《知识图谱》开放共享慕课
查看>>
征稿 | Call for papers on Knowledge Graphs
查看>>
论文浅尝 | 当Hearst还不够时:用分布模型来提升语料库中的上下义关系检测
查看>>
论文浅尝 | DI刊发的那些有关Knowledge Graph的论文
查看>>
论文浅尝 - IJCAI | Knowledge is NOT always you need: 外部知识注入预训练模型的利与弊...
查看>>
论文浅尝 | 利用机器翻译和多任务学习进行复杂的知识图谱问答
查看>>
论文浅尝 | 主题驱动的分子图表示对比学习
查看>>
论文浅尝 | 利用常识知识图谱进行多跳推理的语言生成方法
查看>>
论文浅尝 | 以知识图谱为基础的开放域对话生成的目标规划
查看>>
论文浅尝 | 利用开放域触发器知识改进事件检测
查看>>
OpenKG祝大家端午安康
查看>>
领域应用 | 金融资管领域知识图谱的构建和应用
查看>>