检查magento中分层导航的当前类别

检查magento中分层导航的当前类别,magento,navigation,categories,layer,Magento,Navigation,Categories,Layer,在图层导航中获取当前类别,我正在使用此代码,但它不起作用,请帮助 <?php $_helper = $this->helper('catalog/output') ?> <?php $_category = $this->getCurrentCategory(); > 请使用下面的代码 if(Mage::registry('current_category')) { $cat=Mage::registry('curren

在图层导航中获取当前类别,我正在使用此代码,但它不起作用,请帮助

<?php $_helper = $this->helper('catalog/output') ?>
          <?php $_category = $this->getCurrentCategory(); >


请使用下面的代码

if(Mage::registry('current_category'))
    {
    $cat=Mage::registry('current_category')->getId();
    /* used for category level*/
    }
    else{
    $cat=2; // 2 is root category id
    /* used for serch level*/
    }

希望它能正常工作

如果您想在导航中获取当前类别id,您可以这样做

 <?php $layer = Mage::getSingleton('catalog/layer');
$_category = $layer->getCurrentCategory();
$currentCategoryId= $_category->getId();?>


希望这能解决您的问题。

欢迎。如果答案对您有帮助,请接受。