Through Catalog > Google sitemap I have just generated a sitemap.xml file.

The file itself works perfect. My problem though is, that the file also contains inactive categories.

I can't seem to find any options to exclude these inactive categories from my generated sitemap.xml file.

Do anyone know how this can be solved?

I am using Magento ver.


Try this.

Edit the app/design/frontend/your_package/your_theme/template/catalog/seo/tree.phtml file in your theme. Add an if condition just after the foreach loop which checks for activeness of the $_item.

<?php $_items = $this->getCollection(); ?>
<?php if($_items->getSize()): ?>
    <ul class="sitemap">
        <?php foreach ($_items as $_item): ?>
          <?php if( $_item->is_active ) : ?> 
            <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 endif; ?> 
        <?php endforeach; ?>
<?php else: ?>
    <p class="note-msg">
        <?php echo $this->__('There are no %s available.', $this->getItemsTitle()); ?>
<?php endif ?>
| improve this answer | |

On your frontend when you access this URL you will see only active categories


But if you look at the sitemap by accessing the below URL you will see disabled categories too


The reason is **sitemap.xml** is already generated when the category was active. You have to again generate a sitemap.xml file after disabling any category to reflect the active categories only.

| improve this answer | |
  • Hey Vikran - thanks a lot for the suggestion. I did generate the sitemap.xml at a point where the categories were inactive and they still appear in the xml file :/ Actually the categories appearing in the XML that are inactive have been inactive 1 month prior to me generating the file. – user1231561 Jan 6 '14 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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