Magento – Magento Google sitemap Generation

catalogmagento-1magento-enterprisesitemapsxml

I have generate google sitemap through Magento adminpanel.

I have set Product URL Suffix(html) and Category URL Suffix(html) in the configuration.

This suffix are not showing in sitemap.xml.

It just show like below URL,

www.site.com/men/t-shirt/crew-neck-t-shirts

but its throw 404 with url suffix

And also i have disabled some parent categories, like

-root category
   - Men
     - T-shirt // i have disable this category
       - Crew Neck
       - V Neck

So the sitemap generate for the category like this

www.site.com/men/t-shirt/crew-neck

but i need to show like this

www.site.com/men/crew-neck

how to achieve this. I have checked in the following collection

Mage::getResourceModel('sitemap/catalog_category')->getCollection($storeId)

Mage::getResourceModel('sitemap/catalog_product')->getCollection($storeId)

but no luck.

Any suggestions will be appreciated.

Best Answer

To address one of your initial comments:

"I have set Product URL Suffix(html) and Category URL Suffix(html) in the configuration.

This suffix are not showing in sitemap.xml."

We noticed this bug introduced in EE 1.13. We requested a patch and received the following. I don't believe this is EE specific so hopefully it helps a bit. Also, just upgraded a EE 1.12 site to 1.14 and noticed all the .html extension were dropped from sitemap.xml as well. Yes, having .html is old school and really not of any seo value these days but this bug can really suck if it goes unnoticed.

Warning ... I did not look at the referenced file in community. Use this as a guide, do not try to apply the patch blindly to your community store. Or if you do, at least test it very thoroughly before going live.

__PATCHFILE_FOLLOWS__
diff --git app/code/core/Mage/Sitemap/Model/Sitemap.php app/code/core/Mage/Sitemap/Model/Sitemap.php
index 2213a4f..734bb91 100644
--- app/code/core/Mage/Sitemap/Model/Sitemap.php
+++ app/code/core/Mage/Sitemap/Model/Sitemap.php
@@ -151,11 +151,13 @@ class Mage_Sitemap_Model_Sitemap extends Mage_Core_Model_Abstract
          */
         $changefreq = (string)Mage::getStoreConfig('sitemap/category/changefreq', $storeId);
         $priority   = (string)Mage::getStoreConfig('sitemap/category/priority', $storeId);
+        $urlSuffix  = Mage::helper('catalog/category')->getCategoryUrlSuffix($storeId);
+        $urlSuffix  = ($urlSuffix) ? '.' . $urlSuffix : '';
         $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()),
+                htmlspecialchars($baseUrl . $item->getUrl() . $urlSuffix),
                 $date,
                 $changefreq,
                 $priority
@@ -169,11 +171,13 @@ class Mage_Sitemap_Model_Sitemap extends Mage_Core_Model_Abstract
          */
         $changefreq = (string)Mage::getStoreConfig('sitemap/product/changefreq', $storeId);
         $priority   = (string)Mage::getStoreConfig('sitemap/product/priority', $storeId);
+        $urlSuffix  = Mage::helper('catalog/product')->getProductUrlSuffix($storeId);
+        $urlSuffix  = ($urlSuffix) ? '.' . $urlSuffix : '';
         $collection = Mage::getResourceModel('sitemap/catalog_product')->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()),
+                htmlspecialchars($baseUrl . $item->getUrl() . $urlSuffix),
                 $date,
                 $changefreq,
                 $priority
Related Topic