2014-12-05 79 views
1

我想在magento Footer区域中获取当前类别ID,以便创建一个条件,其中某些内容不会显示在该特定类别中。比如我想做的事: 如果目前的类别是111 不显示社交图标获取Magento Footer中的类别ID

我尝试下面的代码:

<?php$current_id= Mage::getModel('catalog/layer')->getCurrentCategory()->getId();echo $current_id;?> 

问题与上面的代码是,它呼应随机ID和它不会改变我通过不同的类别。

请帮忙。 谢谢。

+0

你有没有尝试一下?法师::注册表( 'current_category') – 2014-12-05 18:15:19

回答

0

从注册表获得当前类别的详细信息:

$_category_detail=Mage::registry('current_category'); 

要获得类别ID:

$category_id= Mage::registry('current_category')->getId(); 

但你不应该在页脚应用缓存 - 请参阅本stackexchange link

4

当你没有获得$这一点,你可以使用Magento的注册表:

$category_id = Mage::registry('current_category')->getId(); 

OR

获取变量集上的阻止对XML

$this->getLayout()->getBlock('product_list')->getCategoryId()