magento - 如何获得属性集名称?

标签 magento attributes magento-1.9

我正在尝试在Magento产品 View 模板中获取属性集名称。我可以通过$_product->getAttributeText('attribute')获取属性值,但是如何获取属性集名称?

我只想显示属于某个属性集的属性。

最佳答案

只要有产品对象,就可以访问其属性集,如下所示:

$attributeSetModel = Mage::getModel("eav/entity_attribute_set");
$attributeSetModel->load($product->getAttributeSetId());
$attributeSetName  = $attributeSetModel->getAttributeSetName();

这将为您提供属性集的名称,然后您可以使用strcmp进行比较:
if(0 == strcmp($attributeSetName, 'My Attribute Set')) {
    print $product->getAttributeText('attribute');
}

希望有帮助!

关于magento - 如何获得属性集名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2091375/

相关文章:

javascript - 自动滚动到 Magento 中的下一个选项

python - 在并发线程中使用类属性

java - 为什么变量在匿名方法中必须是 final 而类字段不需要

php - 如何在 Magento 中实现类似 Related Products 的网格?

php - 产品网格中的自定义 SQL

mysql - 将产品直接导入到 Magento 的 mysql 数据库

magento - 如何检查可配置产品是否缺货?

Magento 税收四舍五入问题

magento - 隐藏价格并禁止客人结账

javascript - jquery.data 返回未定义的结果