Php 在前端获取Magento类别属性

Php 在前端获取Magento类别属性,php,attributes,magento,categories,Php,Attributes,Magento,Categories,我已经创建了一个类别的属性,我想在前端使用它。我试着用与产品相同的方式访问它,但它似乎不起作用。如何在前端显示自定义属性?猜猜看 谢谢试试这个: $cat_attr = $this->getCurrentCategory()->getAttributes(); if(array_key_exists('short_description', $cat_attr)): $_shortDescription=$cat_attr['short_description']->g

我已经创建了一个类别的属性,我想在前端使用它。我试着用与产品相同的方式访问它,但它似乎不起作用。如何在前端显示自定义属性?猜猜看

谢谢

试试这个:

$cat_attr = $this->getCurrentCategory()->getAttributes();
if(array_key_exists('short_description', $cat_attr)):
    $_shortDescription=$cat_attr['short_description']->getFrontend()->getValue($_category);
endif;

我要做的第一件事是对您的category对象执行以下代码

print_r($category->debug());
这将显示是否正在加载该属性。如果看不到属性,可以返回加载对象的控制器,通过添加以下行之一将其添加到选择中:

->addAttributeToSelect('your_attribute')
这将为您加载属性。

非常简单

<?php foreach ($this->getStoreCategories() as $cat): ?>
<?php  $_category=Mage::getModel("catalog/category")->load($cat->getId()); ?>

现在您应该使用getImage方法来检索img属性

<img src="<?php  echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/category/' . $_category->getImage() ?>" />

<?php endforeach ?>
getImage()?>“/>

我有一个自定义属性,并以这种方式在前端显示它

$category_id='10';
$attribute_code='category_categorycolor';
$category=Mage::getModel('catalog/category')->load($category\u id);
echo$category->getResource()->getAttribute($attribute_code)->getFrontend()->getValue($category);

属性的数据类型是什么?