How to Get A List Of All Attributes
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')
->getItems();
foreach ($attributes as $attribute){
echo $attribute->getAttributecode();
echo '<br>';
echo $attribute->getFrontendLabel();
}
//Mage_Eav_Model_Mysql4_Entity_Attribute_Collection
Mage::getResourceModel('eav/entity_attribute_collection')->setEntityTypeFilter(Mage_Catalog_Model_Product::ENTITY);
should do.
We just found a bug, you have to pass the entity_type_id:
$col = Mage::getResourceModel('eav/entity_attribute_collection')->setEntityTypeFilter(4);
DOES
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)
Mage::getResourceModel('eav/entity_attribute_collection')->setEntityTypeFilter($type);
This is to get all attributes
SELECT
eav_attribute_option_value.option_id,
eav_attribute_option_value.`value`,
eav_attribute_option.attribute_id
FROM
eav_attribute_option_value
INNER JOIN eav_attribute_option ON eav_attribute_option_value.option_id = eav_attribute_option.option_id
WHERE
eav_attribute_option.attribute_id = 135
OR eav_attribute_option.attribute_id = 142
-- 135 = BRANDS
-- 142 = TYPES
GROUP BY
eav_attribute_option_value.option_id
ORDER BY
eav_attribute_option_value.`value` ASC