如何在产品列表视图中获取当前的自定义类别属性值?我正在尝试这样
$attribute = Mage::getModel('catalog/category')->getAttributes();
而且我看到它在那里,但是如何获得呢?我的自定义属性名称是catalog_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();
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句