We continue exploring the mechanism of EAV data storage in Magento 2. In this article, we will cover Magento 2 attribute types and how they are presented in the admin. In the 2nd part, we will talk about the role of attribute sets and attribute groups.
How are attributes presented in the admin
Attributes are the name (Label) + field, the value of which can be changed by the administrator.
The following attribute properties affect its display:
- frontend_model is a class that describes the display of the field on the front end section of the site. It’s inherited from Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend and overrides the getValue method to change the output values of the attribute
- frontend_input – the form element that is displayed in the admin section of the site
- frontend_label – the name of the attribute that is displayed in the admin section of the site. It is also displayed on the frontend section of the site unless another value is specified in the eav_attribute_label table (in the attribute settings it is changed on the “Manage Labels” tab)
- frontend_class is used to validate the attribute value in the admin section of the site. In the attribute settings, the property is called Input Validation for Store Owner. For the e-mail validation, the frontend_class property has the value “validate-email”.
Partner With Us
Let's discuss how to grow your business. Get a Free Quote.Magento has the following standard attribute types:
Text Field
It is represented as a text input
Text Area
It is represented as a multi-line field. It is possible to turn on the WYSIWYG editor in its attribute settings.
Date
It appears as a text field for entering dates and a drop-down calendar.
Yes/No
It is represented in the form of a switch that has 2 positions: Yes and No
Multiple Select
It is presented in the form of a list that suggests choosing several values, including none.
Dropdown
It is represented in the form of a drop-down list that suggests choosing only one value.
Price
It appears in the form of a drop-down list.
Media Image
Media Image is represented differently than other fields. There is no field for Media Image. An attribute of the Media Image type adds a role to an image and a video of the product.
Fixed Product Tax
Allows changing taxes for countries and their states. It is presented in the form of a table with a country and a state and the corresponding tax.
Visual Swatch
Visual Swatch is presented to the administrator the same way as the Dropdown. To a user, it is presented in the form of buttons, filled with color, or containing a picture. The field is convenient to use in Configurable products, for example, for color selection.
Text Swatch
It is similar to Visual Swatch, only the contents of the button is text.
The role of attribute sets and attribute groups
An attribute set is needed in order to display different attributes when editing different types of products (like shoes and clothing). For example, we have the shoe_size and clothing_size attributes. For footwear, you need to display the shoe_size attribute, for clothes — clothing_size. Attribute set allows hiding unnecessary attributes, displaying the necessary ones, changing the sorting and grouping. Groups are needed for the convenience of filling the products by an administrator. They have no effect on the logic of loading / storing the products.
Below you can see the Design and Schedule Design Update folders, which are attribute groups. The nested elements are attributes.
Attributes in the product:
That’s it for part 3. The series is to be continued with part 4, in which we will cover additional options when saving EAV entities and customizations based on changes to attribute values.
Magento Webdesign
Take your online store to the next level with BelVG Magento Webdesign
Visit the page
Hi, Samir
Thank you, glad you found it useful.
Thank you for the great posts, they are very useful.