Question

Is Magento attribute value saved in database table static and varchar identical?

when and why to use static backend_type instead of varchar?

Was it helpful?

Solution

EAV is a flexible solution to storing data in a database. Relational databases are ideal for situations where there is a fixed number of descriptors (columns) for an entity row. This works well for, say, storing CMS pages or admin user details. But it does not work well for products as they can have a variable (and semi-infinite) number of descriptors (columns). While the data is split up across five or more tables, the end result in the Magento application is that a product is loaded with the set data as if it was one row (Magento handles the saving and loading operation from multiple tables). In other words, EAV stores its relational-columnar information in rows. Instead of data representing the same entity being stored horizontally, it is stored vertically. EAV is made up of three components. The entity, the attribute, and the attribute value.

Entity: EAV stores the primary key in the entity table (for example, catalog_product_entity). Columns in this table are considered static (see the backend_ type column in the eav_attribute table). You can find the entity types in eav_entity_type.

Attribute: Attributes are stored in eav_attribute. Each attribute represents a "column" in the loaded Magento product.

Value: Each attribute has a backend_type. This value determines which table the values for that attribute are stored in. static means those values are stored in the parent _entity table. Otherwise, look for a table with _ entity_ [backend_ type]. The value is the last column. The first columns relate the value to the entity row, store, and the attribute ID.

OTHER TIPS

Static attributes are attributes stored in the main table of an entity - for catalog products, catalog_product_entity. For example, the attribute sku of catalog products is defined as static. Static attributes are always loaded by Magento, and are useful especially if you want to retrieve information quickly or to optimize lookup of data. A drawback of this type of attributes is that you can't have store-specific values, which is one of the advantages of Magento EAV system.

So, you have to use static backend type when you don't need different value per storeviews.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top