Execution Flows
Attribute loading, entity save, attribute set assignment, and option value resolution.
Attribute loading, entity save, attribute set assignment, and option value resolution.
Loading an EAV entity requires joining multiple value tables to retrieve all attribute values. This flow shows how a product or customer entity is loaded with its EAV data.
Loading multiple entities individually causes N+1 queries. Use collections with
addAttributeToSelect('*') or specific attributes to batch-load values.
Saving an EAV entity writes to multiple tables: the entity table and all relevant value tables based on which attributes have been modified.
The Eav\Model\Config class loads and caches all entity types and their
attributes. This happens once and is cached for subsequent requests.
After adding/modifying attributes, flush the EAV cache:
bin/magento cache:flush eav
For select/multiselect attributes, option values are stored as IDs. The source model resolves these IDs to human-readable labels.
When creating a new entity, it must be assigned an attribute set. This determines which attributes are available and how they're organized in the admin form.
Backend models provide hooks for validation and data transformation during save operations.