Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento-获取类别自定义属性值_Magento - Fatal编程技术网

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。非常感谢你!