How can I fetch a list (array) of all defined product attributes? (basically I need the code and label).


The attributes I need this to dynamically generate ACLs for all product attributes that exist in the shop. (working on a module for Hide Attributes and Other Fields in Product Edit Backend)

  • Ignoring attribute sets?
    – benmarks
    Commented May 10, 2013 at 14:53
  • @benmarks: Yes.
    – Alex
    Commented May 10, 2013 at 15:01

3 Answers 3


If you need a MySQL Query, try that:

select attribute_id, attribute_code, frontend_label from eav_attribute where entity_type_id IN (select entity_type_id from eav_entity_type where entity_type_code = 'catalog_product')

An alternative to Fabian code, if you need a PHP script based on Magento, try this:

$attributes = Mage::getResourceModel('catalog/product_attribute_collection')

foreach ($attributes as $attribute){
    echo $attribute->getAttributecode();
    echo '<br>';
    echo $attribute->getFrontendLabel();
  • Nice. Mage_Catalog_Model_Resource_Product_Attribute_Collection does basically what was Fabian trying to craft. Thanks!
    – Alex
    Commented May 10, 2013 at 15:00
  • you're welcome :-) Commented May 10, 2013 at 15:13
  • how do i get a list of attributes using a group id ? not attribute sets Commented Jul 28, 2014 at 12:29


should do.

We just found a bug, you have to pass the entity_type_id:

$col = Mage::getResourceModel('eav/entity_attribute_collection')->setEntityTypeFilter(4);


The code is the documentation:

if ($type instanceof Mage_Eav_Model_Entity_Type) {
        $additionalTable = $type->getAdditionalAttributeTable();
        $id = $type->getId();
    } else {
        $additionalTable = $this->getResource()->getAdditionalAttributeTable($type);
        $id = $type;

hopefully working solution (updated by @Alex comment)

You have to pass a Mage_Eav_Model_Entity_Type so this should work and is not hardcoded:

$type = Mage::getModel('eav/entity_type')->loadByCode(Mage_Catalog_Model_Product::ENTITY)
  • The collection returns a count of 0 ... I remember there was some kind of API or service class for this, but can't find it ATM.
    – Alex
    Commented May 10, 2013 at 14:24
  • Great - but 4 is hardcoded (even no sooo likely to change). Fix it for an upvote :-)
    – Alex
    Commented May 10, 2013 at 14:34
  • And no, the first line does not work. Mage_Catalog_Model_Product::ENTITY is a string, not an Mage_Eav_Model_Entity_Type
    – Alex
    Commented May 10, 2013 at 14:36
  • I think I got it now :D Commented May 10, 2013 at 14:44
  • But then I'm to late. I'll do, when I pass the 2k rep :p Commented May 10, 2013 at 14:48

This is to get all attributes

                INNER JOIN eav_attribute_option ON eav_attribute_option_value.option_id = eav_attribute_option.option_id
                        eav_attribute_option.attribute_id = 135
                OR eav_attribute_option.attribute_id = 142 
                -- 135 = BRANDS
                -- 142 = TYPES
                GROUP BY
                ORDER BY
                eav_attribute_option_value.`value` ASC
  • Don't want to use plain SQL ...
    – Alex
    Commented Jul 30, 2016 at 8:22
  • thats a good one, thanks
    – dsomnus
    Commented Feb 23 at 9:01

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.