/ Published in: PHP
usefull navigation stuff works in magento 1.5.0.1
http://www.webdesign-blog.ch/?p=17
http://www.pauldonnellydesigns.com/blog/get-parent-category-name-in-magento/
http://www.webdesign-blog.ch/?p=17
http://www.pauldonnellydesigns.com/blog/get-parent-category-name-in-magento/
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php $ella_current_category = Mage::registry('current_category'); $ella_parent_id = $ella_current_category->getParentCategory(); echo $ella_parent_id; ?> Name: <?php $parentname = $this->getCurrentCategory()->getParentCategory()->getName(); echo $parentname; ?> <br />Url: <?php $parenturl = $this->getCurrentCategory()->getParentCategory()->getUrl(); echo $parenturl; ?> <br />Level: <?php $parentlevel = $this->getCurrentCategory()->getParentCategory()->getLevel(); echo $parentlevel; ?> <?php # Set parent Category Id $parentCategoryId = 4; $layer = Mage::getModel('catalog/layer'); $activeCategory = $layer->getCurrentCategory(); $pathIds = $activeCategory->getPathIds(); $layer->setCurrentCategory($parentCategoryId); $currentCategory = $layer->getCurrentCategory(); $childCategories = $currentCategory->getChildrenCategories(); $i = ''; $items = ''; $list1 = ''; $list2 = ''; foreach ($childCategories as $_category) { $items = ' <li class="active">'; } else { $items = ' </li><li>'; } $items .= '<a href="'.$_category->getUrl().'">'.$_category->getName();'</a>'; $items .= '</li> '; $i %2 == 0 ? $list1 .= $items: $list2 .= $items; $i++; } echo ' <ul class="list1">'.$list1. '</ul> '; echo ' <ul class="list2">'.$list2. '</ul> '; ?>