magento get Configurable attributes in attribute set

984 views Asked by At

How can I get all configurable attributes in attribute set?

I was looping all the attribute set then I want to display only its configurable attribute.

3

There are 3 answers

1
Douglas Radburn On BEST ANSWER

You should be able to get an attribute collection and filter it (based on the attribute set) - this would return you all attributes in the specified set that are configurable.

$attributes = Mage::getResourceModel('catalog/product_attribute_collection')
->setAttributeSetFilter($attributeSetId)
->addFieldToFilter("is_configurable", array("eq", "1"))
->getItems();
1
Aapo Kiiso On

There are three conditions for a configurable attribute

I assume that by configurable attributes, you actually mean attributes that can be used to create a configurable product. Douglas Radburn's answer is the right way to do this, it's only missing two more filters. As you can see in the picture above, there are three conditions for using an attribute to create a configurable product. Using the image's message as reference, we can construct the following collection.

$attributes = Mage::getResourceModel("catalog/product_attribute_collection")
->setAttributeSetFilter($attributeSetId)
->addFieldToFilter("frontend_input", "select")
->addFieldToFilter("is_configurable", "1")
->addFieldToFilter("is_global", "1");
0
christian Nguyen On

This will work:

$objAttributes = Mage::getResourceModel('catalog/product_attribute_collection')
->addFieldToFilter("is_configurable", array("1"))
->getItems();