Send the link below via email or IMCopy
Present to your audienceStart remote presentation
- Invited audience members will follow you as you navigate and present
- People invited to a presentation do not need a Prezi account
- This link expires 10 minutes after you close the presentation
- A maximum of 30 users can follow your presentation
- Learn more about this feature in our knowledge base article
Do you really want to delete this prezi?
Neither you, nor the coeditors you shared it with will be able to recover it again.
Make your likes visible on Facebook?
You can change this under Settings & Account at any time.
Magento training - EAV part 1
Transcript of Magento training - EAV part 1
defines EAV as
(EAV), also known as
and open schema is a data model that is used in circumstances where the number of attributes (properties, parameters) that can be used to describe a thing (an "entity" or "object") is potentially very vast, but the number that will actually apply to a given entity is relatively modest. In mathematics, this model is known as a sparse matrix. EAV is also known as
vertical database model
- in Magento, each product has a row in '
- all available attributes in the entire system are stored in '
- the values of these attributes are stored in tables like '
Magento training - EAV part 1
Magento architecture, module structure
Working with DB in Magento
Entity-Attribute-Value (EAV) Model
- in a
, tables have a
fixed number of columns
- in an EAV model, each "
"(a product in our case) has a different
set of attributes (which can contain different number of attributes)
- Magento engineers have built an EAV system out of PHP objects that use MySQL as data-store, actually
an EAV database system on top of a traditional relational db
is somewhat of a “data item”. In Magento, those are for example categories, products and customers.
is again a “data item”, but to differ it from the Entity, in Magento, attributes are for example: Title, Description, Price, etc. for each Product entity.
for simplicity of explanation represents “real value” that is attached to Entity’s Attribute.
: this property is closely connected to the attribute’s backend_type, and its values are dependent on what is set in the backend type. That is why the column backend_table in the table eav_attribute is empty. Despite the dynamic generation of backend_table values, you can explicitly set a table name and store it in the database.
: this has the label of the attribute as shown in admin.
: this class is used to change the presntation form of the values if required. For example,
which is used to format dates.
: this sets how an attribute should be displayed on frontend, basically what kind of input element is used for the attribute in HTML forms.
: this is the label used in frontend when the attribute is displayed
: the method
of the attribute’s frontend model uses the
: this is the primary key
: this is a foreign key of table
: this is a unique code used to identity an attribute
: this property points to a class that contains the attribute's model. Catalog entities (
as attribute model, while customer has
. The values for this property are not set in the db, instead, when loading the attribute models, Magento will look for the entity type assigned to the attribute and load it's proper model.
: this usually has the path of a model class. These model classes are used when saving attribute value in database. Like for example saving of product media images requires some operating to happen before and after save. So those operations are defined in these classes. During these operations the object’s model performs “attribute walking” by calling functions
afterLoad(), beforeSave(), afterSave(), beforeDelete() and afterDelete()
on the attribute backend model.
: this specifies that data type of the attribute. Backend types can be
varchar, int, text, decimal, datetime
. The backend type
is a special case
. Attributes of this type store their data in the entity’s main table, even though the data can be int, decimal, or varchar
' of products, for example)
: source models are mainly used by attributes with frontend_input of type select or multiselect. Source models contain functionality that allows such attributes to have a list of options to choose from.
: this property is used to distinguish between system attributes and attributes created by shop users. The former may not be deleted – and that is why the edit form for such attributes doesn’t display the “delete” button. You still can delete system attributes programmatically, but this would be a bad idea.
: you can provide a default value for the attribute. A default value will come pre-entered into the form input field, or will be used when an entity is created programmatically (e.g. product import), provided the attribute has no explicitly set value.
: setting this attribute to 1 will command the system to check that no two or more entities of the given type share the same value for this attribute. An example could be product SKUs or bar codes.
: you can enter a short descriptive text into this field, if you need a tip displayed next to the attribute’s input field in the backend. For example, see the “Meta Description” field in the product edit form.
: this is the primary key of the table, and also used as the foreign key in
: these are unique codes use to specifies varies entities for wich the EAV table structure is used
l: the base Magento model class for that entity
: there are attribute_model classes. If no attribute model class is given the default eav/attribute is taken
the based entity database table name, where the required attributes of are entity are stored
add flexibility to the attribute system by allowing attributes to be grouped together so that different entity types (or different entities of the same type) could have only those attributes that they really need.
- are represented by the
class and its resource model
. The information on the shop’s attribute sets is contained in the table
: this is the primary key of the table
: this is a foreign key to the table eav_entity_type. This associates the attribute set name to the entity type.
: the name of the attribute set
: order in which attribute sets are shown in admin.
Attribute set groups
- the main role of attribute groups is organizing entity attributes into tabs in the entity edit form.
- you might have already seen and used tabbed attribute forms when editing products and categories.
: primary key
: foreign key of the
: name of the group
: display order of groups
: set group as default
if the old one is removed
Attribute - Attribute set - Group
table contains all relations between an attribute, its attribute set and attribute set group
- you can add almost anything into db
without changing its structure
you can associate attributes to any entity
quick to implement
- a query returning 20 columns normally would consist of 20 self joins in EAV
no grouping of related entity types
PROs and CONs
Backend types of attributes havetheir values are stored in