Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Inactive categories returned by getStoreCategories() ? Also, getIsActive() lies for categories. 
 
Brad Landers
Jr. Member
 
Total Posts:  11
Joined:  2008-04-08
 

We’re in the process of setting up a relatively simple store using Magento, and I’ve run in to something rather curious. We have one category that is set to inactive, but the foreach loop we’re using in our template is returning inactive categories with an empty page title string, but the URL still appears in the nav. You can see it here:

http://store.lovewell.org/

Move your mouse just to the right of “Tickets”. I have run “refresh all” and the bottom three check boxes on the cache management page to no effect. “Is Active” is set to “No” in the admin. Following is our template code for the entire top nav:

<ul id="nav">
<?php foreach ($this->getStoreCategories() as $_category): ?>
    <?php 
echo $this->drawItem($_category?>
<?php 
endforeach ?>
<?php $_loggedIn 
$this->helper('customer')->isLoggedIn(); ?>
<?php 
if($_loggedIn): ?>
    
<li class="right"><a href="/customer/account/logout/">Logout</a></li>
<?php else: ?>
    
<li class="right<?php if($_SERVER["REQUEST_URI"]=='/customer/account/login/'){echo ' active';} ?>"><a href="/customer/account/login/">Login</a></li>
 
<?php endif; ?>
    
<li class="right<?php if($_SERVER["REQUEST_URI"]=='/wishlist/'){echo ' active';} ?>"><a href="/wishlist/">Wishlist</a></li>
    <
li class="right<?php if($_SERVER["REQUEST_URI"]=='/customer/account/'){echo ' active';} ?>"><a href="/customer/account/">Account<?php if($_loggedIn): ?> <span>(<?php echo $this->helper('customer')->getCustomer()->getFirstname() ?>)</span><?php endif; ?></a></li>
    
<?php $_cartQty =  Mage::getSingleton('checkout/cart')->getSummaryQty() ?>
    
<li class="right<?php if($_SERVER["REQUEST_URI"]=='/checkout/onepage/'){echo ' active';} ?>"><a href="/checkout/">Checkout<?php if($_cartQty && $_cartQty 0): ?> <span>(<?php echo Mage::helper('core')->formatPrice(Mage::getSingleton('checkout/cart')->getCartInfo()->getSubtotal()) ?>)</span><?php endif; ?></a></li>
    <
li class="right<?php if($_SERVER["REQUEST_URI"]=='/checkout/cart/'){echo ' active';} ?>"><a href="/checkout/cart/">Cart<?php if($_cartQty && $_cartQty 0): ?> <span>(<?php echo $this->__(($_cartQty==1) ? '1 Item' "%s Items"$_cartQty?>)</span><?php endif; ?></a></li>
</
ul>

Any help would be great!

 
Magento Community Magento Community
Magento Community
Magento Community
 
dan_w
Sr. Member
 
Total Posts:  290
Joined:  2008-01-04
 

I’m pretty sure that the getStoreCategories method will indeed return all categories, active and inactive. Try adding an if condition to your drawItem like this:

<?php foreach ($this->getStoreCategories() as $_category): ?>
   <?if
($_category->getIsActive()):?>
    <?php 
echo $this->drawItem($_category?>
  <?endif
;?>
<?php 
endforeach ?>

That should hopefully do the trick.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Brad Landers
Jr. Member
 
Total Posts:  11
Joined:  2008-04-08
 

Strangely enough the getIsActive() method returns 1 for all categories, even the one that is set to inactive in the admin.

View source, search for DEBUG:
http://store.lovewell.org/

HTML Output:

<ul class="level0">
<
li class="level1 last">
<
a href="http://store.lovewell.org/show-rentals/show-samples"><span>Show Samples</span></a>
</
li>
</
ul></li>
<!-- 
DEBUG$_category->getIsActive() VALUE-->
                    <
li class="level0">
<
a href="http://store.lovewell.org/tickets"><span>Tickets</span></a>
</
li>
<!-- 
DEBUG$_category->getIsActive() VALUE-->
                    <
li class="level0">
<
a href="http://store.lovewell.org/apparel"><span></span></a>
</
li>
<!-- 
DEBUG$_category->getIsActive() VALUE-->
                                    <
li class="right"><a href="/customer/account/login/">Login</a></li>
                     <
li class="right"><a href="/wishlist/">Wishlist</a></li>
            <
li class="right"><a href="/customer/account/">Account</a></li>
                        <
li class="right"><a href="/checkout/">Checkout</a></li>
            <
li class="right"><a href="/checkout/cart/">Cart</a></li>
        </
ul>

Source from template below:

<?php foreach ($this->getStoreCategories() as $_category): ?>
    <?php 
echo $this->drawItem($_category?>
<!-- DEBUG$_category->getIsActive() VALUE<?php echo $_category->getIsActive() ?> -->
<?php endforeach ?>

Image of catalog admin page for Apparel attached.

Image Attachments
apparel_admin.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
Brad Landers
Jr. Member
 
Total Posts:  11
Joined:  2008-04-08
 

Wow, strange. I deleted the category (since it was empty), then re-created it. Now, when I make it inactive, it works as expected. If I can reproduce the problem, I’ll post a bug.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top