2

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. 1.7.0.2

2 Answers 2

3

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; ?>
    </ul>
<?php else: ?>
    <p class="note-msg">
        <?php echo $this->__('There are no %s available.', $this->getItemsTitle()); ?>
    </p>
<?php endif ?>
0

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

http://project_name/catalog/seo_sitemap/category

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

http://project_name/sitemap.xml

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.

1
  • 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. Commented Jan 6, 2014 at 13:13

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.