Architecture
EAV data model, entity types, value tables, attribute sets and groups.
EAV data model, entity types, value tables, attribute sets and groups.
The Entity-Attribute-Value (EAV) pattern separates attribute storage from entity storage, allowing unlimited custom attributes without modifying the database schema. This flexibility comes at the cost of query complexity.
Entity Type: The "class" of entity (product, customer).
Attribute Set: A collection of attributes assigned to an entity.
Attribute Group: A tab within an attribute set for organization.
Attribute: A single property (name, color, price).
EAV stores attribute values in separate tables based on data type. This allows proper
indexing and type-specific operations. The backend_type column in
eav_attribute determines which table stores the value.
All value tables share a common structure with store-scoped values:
Attributes with backend_type='static' are stored directly in the entity
table (e.g., sku in catalog_product_entity). This avoids
JOINs for frequently accessed attributes.
Each attribute can have three types of associated models that control its behavior during save, load, and display operations.
Validates and transforms data before save. Examples: ArrayBackend, Datetime, Increment. Method: beforeSave(), afterSave(), validate()
Formats values for display. Examples: Datetime (date formatting), Image (generates URLs). Method: getValue()
Provides options for select/multiselect inputs. Examples: Boolean, Table, Config. Method: getAllOptions(), getOptionText()
Each entity type defines its storage configuration in eav_entity_type.
This tells EAV how to load and save entities of that type.