Skip to content

Magento_Eav

Entity-Attribute-Value framework powering flexible attribute systems for products, categories, customers, and addresses.

Phase 1 - Core Commerce
484
PHP Files
36
API Interfaces
284
Model Classes
17
DB Tables
5
REST Endpoints
20+
DI Preferences

Module Overview

The Magento_Eav (Entity-Attribute-Value) module provides Magento's flexible attribute system that powers products, categories, customers, and customer addresses. Instead of fixed database columns, EAV stores attribute values in separate tables organized by data type, enabling unlimited custom attributes without schema changes.

This module defines the core EAV architecture: entity types (product, category, customer), attributes (name, price, color), attribute sets (groupings of attributes), and attribute groups (tabs in admin forms). It also provides backend models for validation, frontend models for display, and source models for option values.

Key insight: While EAV provides flexibility, it comes with performance costs due to multiple JOINs required to load entity data. Magento uses "flat tables" (denormalized copies) for catalog data to optimize frontend queries.

EAV vs Flat Tables

EAV tables are the source of truth but slow for queries. Products and categories use flat indexer tables (catalog_product_flat_*, catalog_category_flat_*) for frontend performance. Always use flat tables when available for read operations.

Key Components

Eav\Model\Config
Central configuration for entity types and attributes. Heavily cached.
Eav\Model\Entity\AbstractEntity
Base resource model for all EAV entities. Handles multi-table saves.
Eav\Model\Entity\Attribute
Attribute model with backend, frontend, and source model references.
Eav\Model\Entity\Attribute\Set
Attribute set model for grouping attributes per entity type.
Eav\Model\Entity\Attribute\Group
Attribute group model for organizing attributes into tabs.
Eav\Model\Entity\Attribute\Backend\*
Backend models for validation and data transformation on save.
Eav\Model\Entity\Attribute\Frontend\*
Frontend models for value formatting on display.
Eav\Model\Entity\Attribute\Source\*
Source models for select/multiselect option values.
AttributeRepository
Repository for CRUD operations on attributes with search criteria.

REST API Endpoints

Method Endpoint Service Interface Description
GET /V1/eav/attribute-sets/list AttributeSetRepositoryInterface::getList List all attribute sets
GET /V1/eav/attribute-sets/:id AttributeSetRepositoryInterface::get Get attribute set by ID
POST /V1/eav/attribute-sets AttributeSetManagementInterface::create Create new attribute set
PUT /V1/eav/attribute-sets/:id AttributeSetRepositoryInterface::save Update attribute set
DELETE /V1/eav/attribute-sets/:id AttributeSetRepositoryInterface::deleteById Delete attribute set

Database Tables Overview

eav_entity_type
Entity type definitions (product, category, customer, etc.)
eav_attribute
Attribute definitions with backend/frontend/source model references.
eav_attribute_set
Attribute set definitions per entity type.
eav_attribute_group
Attribute groups within sets (admin form tabs).
eav_entity_attribute
Links attributes to sets/groups with sort order.
eav_entity_*
Value tables: varchar, int, decimal, text, datetime.
eav_attribute_option
Options for select/multiselect attributes.
eav_attribute_option_value
Store-scoped option labels.
eav_attribute_label
Store-scoped attribute labels.