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 ....................................... ........................................ ............