为了解决magento将当前日期放入站点地图的lastmod字段的问题。这导致了较低的爬网率,我修改了Sitemap.php中的日期( app/code/local/Mage/Sitemap/Model/Sitemap.php)如下:
/*
* Generate categories sitemap
**/
$changefreq = (string)Mage::getStoreConfig('sitemap/category/changefreq', $storeId);
$priority = (string)Mage::getStoreConfig('sitemap/category/priority', $storeId);
$collection = Mage::getResourceModel('sitemap/catalog_category')->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()),
substr(Mage::getModel('catalog/category')->load($item->getId())->getUpdatedAt(),0,10), //---> here the changes
$changefreq,
$priority
);
$io->streamWrite($xml);
}这是有效的,但我注意到我的sitemap.xml (www.edenglamode.com/sitemap.xml)中的一些最后的模块是空的,所以谷歌抱怨这个问题,我尝试了一些修改产品并重新生成网站地图,但没有办法
<url>
<loc>
http://www.edenglamode.com/robe-courte-sexy-bustier-avec-ceinture.html
</loc>
<lastmod/>
<changefreq>hourly</changefreq>
<priority>1.0</priority>
</url>
你能帮我解决这个问题吗?
发布于 2012-09-21 02:47:19
如果产品的lastmod时间为空,那么您应该加载产品,将日期添加为lastmod,保存产品并将日期写入XML。下一次它不会有问题,因为lastmod存在。然后,它将能够写出站点地图条目,而不必等待Magento加载'n‘保存产品的时间。
我能不能问一下,你是怎么结束没有最后一次的?您是否批量导入产品,而没有在管理中打开它们?
https://stackoverflow.com/questions/12512977
复制相似问题