About router name URL rewriting-frontname rewrite frontname rewriting!

Source: Internet
Author: User

For tags

That is, if the URL contains a tag, you want to change it to wholesale or another method,

1

Refer to the blog plug-in method:

Add an event to 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>

 

Then, use the following method:

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 );
}

This method is flexible. You can define the router in the background.

 

 

2

This method is relatively simple. Specifically, it creates a new module, then routername is the name you want to modify, and then

Event

<Controller_front_init_routers>

Process and judge. If the conditions are met, execute the following statement:

 

 

 

$ Request-> setmodulename ('tag ')
-> Setcontrollername ('product ')
-> Setactionname ('LIST ');

 

Then it is transferred to the corresponding module, but the URL will not change.

If the router of this module is wholesale, the URL will not jump and the Code for tag/product/list will be executed:

3

This is the most stupid way. We recommend you change the tag and change its source code !!!

 

Magneto ....................................... ........................................ ............

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.