2012-09-20 27 views
0

爲了解決這個事實,magento將當前日期放入站點地圖的lastmod字段中。這導致不良率爬,我修改的日期Sitemap.php(應用程序/代碼/本地/法師/地圖/型號/ Sitemap.php)是這樣的:網站地圖magento lastmod

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

那的作品,但我注意到一些的lastmod是空在我的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> 

你能幫我解決這個問題嗎?

回答

0

如果產品lastmod時間爲NULL,則應加載產品,將DATE添加爲lastmod,保存產品並將DATE寫入XML。下一次它不會像lastmod一樣存在問題。然後,它將能夠寫出網站地圖條目,而無需等待Magento加載'n'保存產品的年齡。

我可以詢問你最後沒有lastmod時間嗎?您是否全面導入產品,而不是在管理員中打開它們?

+0

這些說明適用於我:http://www.semantium.de/msemantic/readme.html – Theodores

+0

我有很多產品沒有lastmod :-(我剛剛修改了幾天前的Sitemap文件,我的產品已經在那裏,我不能一一加載它們,我必須找出最好的方法來做到這一點,如果我使用默認的站點地圖文件,我所有的最後日期,但與當前日期magento,我也注意到所有產品之前創建到最後一個版本有lastmod這個湖 –

+0

謝謝你現在好了 –