本文共 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/