Get Current Category Level in Magento

There are two ways to get Current Category Level in Magento:

1) For category view page, use the following code snippet to get the current category level:

<?php $level= $this->getCurrentCategory()->getLevel(); ?>

2) For other pages, use the following code snippet to get the current category level:

<?php $currentCategoryObj = Mage::registry(‘current_category’); ?>

<?php $level = $currentCategoryObj->getLevel();  ?>

 

Leave a Reply