Magento:如何从tabs.html中输出current_category id


Magento: how do I output current_category id from within tabs.phtml

我已经能够在大多数其他模板页面上输出类别和产品数据,但我仍然无法在tabs.html中做到这一点。我尝试了以下方法,但都没有成功:

$currentCategory = Mage::registry('current_category');
$currentCategoryId = $currentCategory['id'];

$currentCategoryId= Mage::getModel('catalog/category')->load($this->getCategoryId());
$currentCategory = Mage::registry('current_category');
$currentCategoryId = $currentCategory->getId(); 

或者你可以在下面做

$currentCategoryId = $currentCategory->getData('id');

如果注册表有类别会话,这将起作用。

$currentCategory = Mage::registry('current_category');
var_dump($currentCategory->debug());
exit;

这将打印currentcategory对象。由此,您可以确定getdata('variablename')将提供哪些所有变量。

$currentCategoryId = $currentCategory->getData('id');

肯定会奏效的。

我建议使用->debug()函数,因为该函数提供了更多的细节,可以在使用Magento时用于调试和总结。