One of the strength of Magento is the architect of the data layer vertically which allows us to create dynamic attributes. They call this design by EAV structure. With this data architecture, the SQL query to find out a particular attribute values or names can be a challenging task.

Here are the cheat sheet to retrieve those attributes (EAV).

1. Query to find different type of entity available

SELECT * FROM eav_entity_type

2. Then use that entity type above to find EAV available for that entity using this query:

SELECT et.*,att.attribute_code,g.attribute_group_name,eset.attribute_set_name
FROM eav_entity_attribute et
INNER JOIN eav_attribute att ON att.attribute_id=et.attribute_id
INNER JOIN eav_attribute_group g ON g.attribute_group_id=et.attribute_group_id
INNER JOIN eav_entity_type etype ON etype.entity_type_id=et.entity_type_id
INNER JOIN eav_attribute_set eset ON eset.entity_type_id = etype.entity_type_id AND eset.attribute_set_id=et.attribute_set_id
WHERE etype.entity_type_code=’{replace with entity type}’;

Magento EAV

Magento EAV

Comment