我正在尝试在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/