I am trying to create a custom Eav entity in Magento 2.
I have gone through two core eav entity modules in Magento which are Catalog and Customer.
There are a couple of things which I found strange in these two modules.
Setup Files
'entity_type_id' => self::CATEGORY_ENTITY_TYPE_ID
'entity_type_id' => \Magento\Customer\Api\CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER
It seems like Magento sets entity_type_id
statically here.
Q1: Why Magento sets entity_type_id
statically here though it manages dynamically within eav_entity_type
table?
Q2: When are the records in eav_entity_type
table created?
Q3: If I need to create a custom EAV model, the how should I define entity_type_id
for that model
entity_type_id
is AUTO_INCREMENT but the purpose to define as constant is to retrieve it easily. i know you are confuse if you have another eav module in that case your id may conflict with it but that is the only way. go with id 9 and in case of conflict you need to just change your constant value.entity_type_id'
Should be dynamic