How can I get the list of attributes of an attribute set that are not present in the default attribute set?

I tried the following codes:

$attributeSetId = Mage::getModel('eav/entity_attribute_set')
$attributes = Mage::getModel('catalog/product_attribute_api')

echo '<pre>';

But this returned an array with all the attributes including the attributes of default attribute set whereas I just needed the attributes that only belonged to my custom attribute set.

1 Answer 1


Since no one answered my question, I tried a bit of workaround and this was what I came up with and actually worked my purpose. Hope it helps for anyone with the same issue later.

public function getSpecificAttributes($product) {
    //to get ids of all the attributes in the default attribute set
    $entityTypeId = Mage::getModel('eav/entity')
    $attributeSetName = 'Default';
    $defaultAttributeSetId = Mage::getModel('eav/entity_attribute_set')
            ->addFieldToFilter('attribute_set_name', $attributeSetName)

    $defaultAttributes = Mage::getModel('catalog/product_attribute_api')->items($defaultAttributeSetId);
    $defaultAttributeCodes = array();
    foreach ($defaultAttributes as $attributes) {
        $defaultAttributeCodes[] = $attributes['code'];

    //get ids of all the attributes in the attribute set specific to the current product
    $attributeSetId = $product->getAttributeSetId();
    $specificAttributes = Mage::getModel('catalog/product_attribute_api')->items($attributeSetId);
    $attributeCodes = array();
    foreach ($specificAttributes as $attributes) {
        $attributeCodes[] = $attributes['code'];

    $currentAttributes = array_diff($attributeCodes, $defaultAttributeCodes);
    return $currentAttributes;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.