业务形式:本司专业提供深圳外贸网站建设,外贸网站建设,深圳网站建设,ZenCart模板
环球商务国际 版权所有 ©2005-2014 35EBS.All rights reserved.
粤ICP备05007577号
Processed in 0.018313 second(s) , 38 queries
如想屏蔽掉cms pages相关的单页面,首页在/app/code/core/Mage/Sitemap/Model这个路径下找到Sitemap.php,打开以后找到Generate cms pages sitemap(大概在171行左右)原文如下
/**
* Generate cms pages sitemap
*/
$changefreq = (string)Mage::getStoreConfig('sitemap/page/changefreq', $storeId);
$priority = (string)Mage::getStoreConfig('sitemap/page/priority', $storeId);
$collection = Mage::getResourceModel('sitemap/cms_page')->getCollection($storeId);
foreach ($collection as $item) {
$xml = sprintf('<url><loc>%s</loc><lastmod>%s</lastmod><changefreq>%s</changefreq><priority>%.1f</priority></url>',
htmlspecialchars($baseUrl . $item->getUrl()),
$date,
$changefreq,
$priority
);
$io->streamWrite($xml);
}
unset($collection);
修改为:
/**
* Generate cms pages sitemap
$changefreq = (string)Mage::getStoreConfig('sitemap/page/changefreq', $storeId);
$priority = (string)Mage::getStoreConfig('sitemap/page/priority', $storeId);
$collection = Mage::getResourceModel('sitemap/cms_page')->getCollection($storeId);
foreach ($collection as $item) {
$xml = sprintf('<url><loc>%s</loc><lastmod>%s</lastmod><changefreq>%s</changefreq><priority>%.1f</priority></url>',
htmlspecialchars($baseUrl . $item->getUrl()),
$date,
$changefreq,
$priority
);
$io->streamWrite($xml);
}
unset($collection);
*/
也就是把这段给注释掉,这样就屏蔽掉那些单页面了
然后就是sitemap中没有首页,这个需要我们自己加上了,这个是我参考别人的,代码如下:
/**
* Generate index sitemap
*/
$xml= sprintf('<url><loc>%s</loc><lastmod>%s</lastmod><changefreq>daily</changefreq><priority>%.1f</priority></url>',
htmlspecialchars($baseUrl),
$date,
$changefreq,
$priority
);
$io->streamWrite($xml);
以上这段代码加在以下代码前就可以了:
$io->streamWrite('</urlset>');
$io->streamClose();
$this->setSitemapTime(Mage::getSingleton('core/date')->gmtDate('Y-m-d H:i:s'));
$this->save();
return $this;
}
}