tags:

views:

75

answers:

1

Hi,

I am trying to get attribute set name in Magento product view template. I can get attribute value by $_product->getAttributeText('attribute'), but how do I get attribute set name?

I would like to display an attribute only if it is belong to a certain attribute set.

+2  A: 

Whenever you have a product object, you can access its attribute set like this:

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

This will give you the name of the attribute set, which you can then compare using strcmp:

if(0 == strcmp($attributeSet, 'My Attribute Set') {
    print $_product->getAttributeText('attribute');
}

Hope that helps!

Thanks, Joe

(edited because my previous answer was just wrong)

Joseph Mastey