8

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.

7
  • So just to clarify, you're wanting to remove the sub category from all URL's?
    – zigojacko
    Commented Jun 13, 2014 at 8:25
  • @zigojacko Yes, Not all sub category only disabled category.
    – VijayS91
    Commented Jun 13, 2014 at 9:07
  • Why not just rename the category Men to Men's T-Shirts? If you're disabling a category which holds sub categories then is there even a need to keep that parent category - in this instance T-Shirts?
    – zigojacko
    Commented Jun 13, 2014 at 10:32
  • Or take the simpler approach, don't generate sitemaps. It's the same as giving Google the keys to your front door, and the question is - given that they generate 70% of their revenue via Adwords - do you trust them that much. Using any Google tools allows them to instantly profile your site and rank you accordingly - why make it so easy - but this is a business point not technical one - except they are completely interconnected.
    – user2935
    Commented Aug 12, 2014 at 20:30
  • My question is why does the url www.site.com/men/t-shirt/crew-neck-t-shirts throw a 404. I have tried this myself and disabled a parent category and the full links still work well. Commented Aug 13, 2014 at 11:47

3 Answers 3

4

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
2

I haven't tested in Enterprise 1.13 but my extension works great for the community editions of magento and should work with EE as well.

To test your problem I created a parent category called "Test"...disabled it. Created a sub-category called "test-subcat" and have it enabled with .html suffix enabled for category urls.

I can confirm that the .html gets added to the category urls and disabled categories aren't included in the sitemap. If you want your category to be displayed at www.site.com/men/crew-neck, then just move "crew-neck" out of the "T-Shirts" category and place it under the "Men" parent category.

1

If you wish to hide inactive categories in the Magento sitemap:-

Open up /app/design/frontend/package/theme/template/catalog/seo/tree.phtml (or copy the file from base into this location):-

This file renders the list of items in sitemap.

<?php $_items = $this->getCollection(); ?>
<?php if($_items->getSize()): ?>
    <ul class="sitemap">
        <?php foreach ($_items as $_item): ?>
            <li class="level-<?php echo $this->getLevel($_item) ?>" <?php echo $this->getLevel($_item)?'style="padding-left:' . $this->getLevel($_item, 2) . '0px;"':'' ?>><a href="<?php echo $this->getItemUrl($_item) ?>"><?php echo $_item->name ?></a></li>
        <?php endforeach; ?>
    </ul>
<?php else: ?>
    <p class="note-msg">
        <?php echo $this->__('There are no %s available.', $this->getItemsTitle()); ?>
    </p>
<?php endif ?>

You could check if $_item is active before displaying:-

<?php $_items = $this->getCollection(); ?>
<?php if($_items->getSize()): ?>
    <ul class="sitemap">
        <?php if( $_item->is_active ) : ?>
            <?php foreach ($_items as $_item): ?>
                <li class="level-<?php echo $this->getLevel($_item) ?>" <?php echo $this->getLevel($_item)?'style="padding-left:' . $this->getLevel($_item, 2) . '0px;"':'' ?>><a href="<?php echo $this->getItemUrl($_item) ?>"><?php echo $_item->name ?></a></li>
            <?php endforeach; ?>
        <?php endif; ?> 
    </ul>
<?php else: ?>
    <p class="note-msg">
        <?php echo $this->__('There are no %s available.', $this->getItemsTitle()); ?>
    </p>
<?php endif ?>

If this is all you wanted to do, give that a whirl and see if that resolves the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.