Skip to content

Plugins & Observers

DI preferences, cache invalidation plugins, backend/frontend/source model patterns.

DI Preferences

The EAV module defines preferences to bind interfaces to concrete implementations for the attribute system.

API Interface Bindings

Interface Implementation
AttributeRepositoryInterface Magento\Eav\Model\AttributeRepository
AttributeSetRepositoryInterface Magento\Eav\Model\AttributeSetRepository
AttributeSetManagementInterface Magento\Eav\Model\AttributeSetManagement
AttributeGroupRepositoryInterface Magento\Eav\Model\Attribute\GroupRepository
AttributeManagementInterface Magento\Eav\Model\AttributeManagement
AttributeOptionManagementInterface Magento\Eav\Model\Entity\Attribute\OptionManagement
AttributeOptionUpdateInterface Magento\Eav\Model\Entity\Attribute\OptionManagement

Data Interface Bindings

Interface Implementation
Data\AttributeInterface Magento\Eav\Model\Entity\Attribute
Data\AttributeSetInterface Magento\Eav\Model\Entity\Attribute\Set
Data\AttributeGroupInterface Magento\Eav\Model\Entity\Attribute\Group
Data\AttributeOptionInterface Magento\Eav\Model\Entity\Attribute\Option
Data\AttributeOptionLabelInterface Magento\Eav\Model\Entity\Attribute\OptionLabel
Data\AttributeFrontendLabelInterface Magento\Eav\Model\Entity\Attribute\FrontendLabel

Internal Bindings

Interface Implementation
PropertyMapperInterface Magento\Eav\Model\Entity\Setup\PropertyMapper\Composite
AttributeLoaderInterface Magento\Eav\Model\Entity\AttributeLoader
UniqueValidationInterface Magento\Eav\Model\Entity\Attribute\UniqueValidator
ReservedAttributeCheckerInterface Magento\Eav\Model\ReservedAttributeChecker
CustomAttributeTypeLocatorInterface Magento\Eav\Model\TypeLocator

Plugins

The EAV module defines plugins for caching and cache invalidation.

storeLabelCaching
Magento\Eav\Plugin\Model\ResourceModel\Entity\Attribute
Magento\Eav\Model\ResourceModel\Entity\Attribute
after afterGetStoreLabelsByAttributeId

Caches store-scoped attribute labels after loading to avoid repeated database queries.

clean_cache
Magento\Framework\App\Cache\FlushCacheByTags
Magento\Eav\Model\Entity\AbstractEntity
after afterSave / afterDelete

Invalidates cache tags when EAV entities are saved or deleted to ensure cache consistency.

Virtual Types

EAV defines virtual types for search criteria processing and collection filtering.

Eav\Model\Api\SearchCriteria\CollectionProcessor
Processors: FilterProcessor, SortingProcessor, PaginationProcessor
AttributeCollectionProcessor
Specialized collection processor for attribute repositories
AttributeSetCollectionProcessor
Collection processor with entity_type_code filter support
AttributeGroupCollectionProcessor
Collection processor for attribute groups with default sort order
configured_eav_cache
Cache instance with identifier 'eav' for EAV configuration caching

Backend/Frontend/Source Model Patterns

EAV attributes use model patterns for validation, display, and option handling.

Backend Models
  • Backend\DefaultBackend - Base backend
  • Backend\ArrayBackend - Multiselect handling
  • Backend\Datetime - Date formatting
  • Backend\Increment - Auto-increment
  • Backend\Serialized - Array serialization
Frontend Models
  • Frontend\DefaultFrontend - Base frontend
  • Frontend\Datetime - Date display
Source Models
  • Source\Table - Database options
  • Source\Boolean - Yes/No options
  • Source\Config - Config-based options
  • Source\Store - Store options

EntityManager Extensions

EAV integrates with the EntityManager framework for CRUD operations.

// EntityManager AttributePool extension for EAV handling <type name="Magento\Framework\EntityManager\Operation\AttributePool"> <arguments> <argument name="extensionActions" xsi:type="array"> <item name="eav" xsi:type="array"> <item name="default" xsi:type="array"> <item name="read"> Magento\Eav\Model\ResourceModel\ReadHandler </item> <item name="create"> Magento\Eav\Model\ResourceModel\CreateHandler </item> <item name="update"> Magento\Eav\Model\ResourceModel\UpdateHandler </item> </item> </item> </argument> </arguments> </type> // These handlers manage EAV attribute values during entity CRUD