1

I've just noticed while testing that my sitemap shows inactive categories in on my Magento ver. 1.9.1.0 install. I saw a post that seems to address the issues via the app/design/frontend/base/default/template/catalog/seo/tree.phtml link. My problem is I get a n error code when I try this.

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

I think because the if statement is not being closed properly. When I trying joining the if statements like this.

<?php $_items = $this->getCollection(); ?>
<?php if($_items->getSize && is_active()): ?>
    <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>

I don't get an error but all that shows is the php else message "There are no available." any help would be appreciated.

  • Marius getting error code "Parse error: syntax error, unexpected 'endif' (T_ENDIF)" – Dutch Feb 9 '15 at 8:11
2

Dutch,Please goto class Mage_Catalog_Block_Seo_Sitemap_Tree_Category and here i have see that category collection is filter by active . Default code is right.You may need reindex.

Please out an condition at...

<?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>

Change the above code to

   <?php
    if(get_class($this)=='Mage_Catalog_Block_Seo_Sitemap_Tree_Category'): ?>
    <?php foreach ($_items as $_item): ?>
        <?php if($_item->getActive()==1) ?>
                <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: ?>

    <?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; ?>
  • Amit can you better define the file path for me and which default code do you refer to. I reindexed and same error? – Dutch Feb 9 '15 at 6:44
  • app\code\core\Mage\Catalog\Block\Seo\Sitemap\Tree\Category.php – Amit Bera Feb 9 '15 at 7:20
0

Thanks Amit for your assistance turns out you were right my problem was that I had the items listed under a main category which was inactive. The subcategories however were all designated as active so they were showing on the sitemaps category view. Once I set everything to inactive they stopped showing. Thx

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.