Get Free Audit

EAV in Magento 2

Jan 30, 2018

14515 Andrey Litvin

EAV in Magento 2

The Entity-Attribute-Value model is a data model intended for describing entities where the number of attributes is expected to be enormous, but in fact, the number of attributes to be used in the entity is small.

Entity stores information about the type of the data being stored. In the case of Magento, this is customer product, category, and etc.
Attribute is the individual property of each entity (name, weight, email address).
Value is the value of a given entity and attribute.

bg request prestashop
Lorem ipsum dolor sit amet consectetur Lorem ipsum dolor sit amet consectetur TEST LINK CTA

The benefits the EAV model brings are following:
  • Flexible versatile data structure (it’s possible to change the number of properties without having to change the database schema).
  • When adding a new attribute for a given entity, we have a possibility to use it in other entities.
  • Quick to implement.

Database schema for EAV entities:

  • eav_entity – (E) The Entity table.
  • eav_entity_attribute (A) The Attrubute table
  • eav_entity_{type} (V) – The Value table. {type} – datetime, decimals, int, text and varchar.

Diagram with eav_* tables:

EAV in Magento 2

Which EAV entities are there in Magento 2:

The list of entities can be found in the eav_entity_type table:

  • customer
  • customer_address
  • catalog_category
  • catalog_product

Which EAV entity types are there in Magento 2:

  • eav_entity_int
  • eav_entity_varchar
  • eav_entity_text
  • eav_entity_decimal
  • eav_entity_datetime
magento development services

Magento 2 Development

Take your online store to the next level with BelVG Magento 2 Development

Visit the page

Entities catalog_product in Magento 2

In order to understand the EAV model in Magento 2, let’s consider  “catalog_product” example, the type of tables used to create attributes, the functions of attributes in the attribute set and attribute group. Besides, we have a closer look at the tables used to assign the product with an attribute. At every step, there’s SQL code being generated by Magento.

  1. Create an attribute for each type with default data.
  2. Create attribute set with new attributes.
  3. Add new attribute group in the attribute set.
  4. Consider the tables used to assign the product with an attribute.

1. First off, we create an attribute for each type with default data. You can perform it in the admin panel: Stores – Attributes – Product Attributes – Add New Attribute

  • Text Field
  • Text Area
  • Date
  • Yes/No
  • Multiple Select
  • Dropdown
  • Price
  • Media Image
  • Fixed Product Tax
  • Visual Swatch
  • Text Swatch

1.1 Create product attribute with text field type


If we forgot to assign the label for attribute, there would be a line added:


 1.2. Create product attribute with text area type


 1.3. Create product attribute with date type


1.4. Create product attribute with yes/no type


1.5. Create product attribute with multiple select type

Andrey_Dubina
Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Andrey


 1.6. Create product attribute with dropdown type


 1.7. Create product attribute with price type


1.8. Create product attribute with media image type


1.9. Create product attribute with Fixed Product Tax type


The second part of the article is to be published soon. Stay tuned!

magento webdesign

Magento Webdesign

Take your online store to the next level with BelVG Magento Webdesign

Visit the page
Lorem ipsum dolor sit amet consectetur Lorem ipsum dolor sit amet consectetur. Ornare consectetur et massa vivamus. Sit blandit donec ornare semper. Nisl vel elit Contact

2 Comments

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *