Looking for an easy way to find the sibling categories in Magento? I know I was! But then I stumbled upon this neat little trick. Try this:
1 2 3 4 5 6 7 8 |
<?php $_siblingCategories = $_currentCategory->getParentCategory()->getChildrenCategories(); ?> <ul> <?php foreach($_siblingCategories as $_siblingCategory): ?> <li> <?php echo $_siblingCategory->getName(); ?> </li> <?php endforeach; ?> </ul> |
Thanks go out to Tim Bezhashvyly for this neat little trick.
Visitors give this article an average rating of 2.0 out of 5.
How would you rate this article?
★ ★ ★ ★ ★
Did not work at all using 1.9.2.x with all patches installed. Page failed upon loading this code.