获取magento中的当前类别

时间:2014-01-17 14:40:37

标签: magento categories

我试图从 catalog / product / view.phtml获取当前类别

<?php 
$_helper = $this->helper('catalog/output');
$item = $this->getProduct();
$curCat = Mage::registry('current_category');

if($curCat && $curCat->getId() == Mage::helper('function')->NEWS_CAT_ID) {
        // do stuff
}
?>

这种方法的主要问题是;我得到parrent category_ID(2)而不是子category_ID(10)。我该如何解决这个问题?

2 个答案:

答案 0 :(得分:0)

SinisterGlitch,你是从目录搜索页面转到这个页面....注册表已保存当前类别默认类别,其ID为2.这意味着从类别的产品调用保存为当前类别

答案 1 :(得分:0)

检查您的根类别表单管理面板您可能也将此产品添加到根类别。

相关问题