Having an attribute set, how can I get a list of the attributes it contains (or better yet, just the custom attributes that don't belong to the Default attribute set)?
The attribute set itself can be obtained in several ways, such as:
$entityTypeId = Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId();
$attributeSet = Mage::getResourceModel('eav/entity_attribute_set_collection')->setEntityTypeFilter($entityTypeId)->addFilter('attribute_set_name', 'Default');
Note that I need to use the attribute set, so getting the list of attributes from a product is not the solution I am looking for.
Mage::getModel('catalog/product_attribute_set_api')->items();
Gets the attribute sets themselves.
Mage::getModel('catalog/product_attribute_api')->items($setId);
Gets the attributes inside the attribute sets.
I believe the answer lies in this model
Mage::getModel('catalog/product_attribute_set_api')->items($setId);
The class is Mage_Catalog_Model_Product_Attribute_Api
it seems to have two methods. The items() methods seems to do what you ask i.e. "Retrieve attributes from specified attribute set"
I hope that helps :)
The right way:
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')
->setAttributeSetFilter($attributeSetId)
->getItems();
var_dump($attributes);
You can change resources 'catalog/product_attribute_collection' (customer, ...) And Set ID $attributeSetId
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With