Magento-获取类别自定义属性值
如何在产品列表视图中获取当前自定义类别属性值? 我试着这样做Magento-获取类别自定义属性值,magento,Magento,如何在产品列表视图中获取当前自定义类别属性值? 我试着这样做 $attribute = Mage::getModel('catalog/category')->getAttributes(); 我看到它就在那里,但是怎么才能得到呢? 我的自定义属性名称是catalog\u pdf 也这样尝试过,但一无所获: $attribute = Mage::getModel('catalog/category')->getAttribute('catalog_category','catalo
$attribute = Mage::getModel('catalog/category')->getAttributes();
我看到它就在那里,但是怎么才能得到呢?
我的自定义属性名称是catalog\u pdf
也这样尝试过,但一无所获:
$attribute = Mage::getModel('catalog/category')->getAttribute('catalog_category','catalog_pdf');
这应该行得通。
如果您在产品列表中,那么您应该在
Mage::registry('current_category');
所以你要这样做:
$category = Mage::registry('current_category');
if ($category){ //this is necessary in case you are in a product listing that is's not a category
$value = $category->getData('catalog_pdf');//catalog_pdf is the attribute code
//or
//$value = $category->getCatalogPdf();
}
这应该起作用:
$id = $this->getCurrentCategory()->getId();
$category = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getCode()->getId())->load($id);
echo $category->getData('catalog_pdf');
//or
echo $category->getCatalogPdf();
编辑为包含缺少的get您正在保存我的live。非常感谢你!