Have you ever ticked a ‘Use Default Value’ checkbox for Price (in store view level) and noticed the changes in the database?

If you tick the ‘Use Default Value’ checkbox for any product attribute (say Price) in store view level and save it. This will delete the related row in the database for that attribute, for the specific product, for that store id. And attribute will now take the default value.

Lets explain this scenario in detail.

1st Approach

Fig: Before Checkbox Tick

Fig: After Checkbox Tick

So if you want to set the default value for any attribute, you can just tick the checkbox and save the product. This process can be overhead in case of hundreds of product.

2nd Approach

Alternatively, you can use SQL approach which is actually the background operation.1 Find entity_type_id

Introduction

Magento is a giant e-commerce application having more than 300 tables. It uses an eav model concept and provides different complex features which makes the database huge.

Sometimes you may wonder what’s the database size of your Magento database or individual tables so that you can work on some optimization task or freeing some of your server space. Here we are going to discuss some SQL queries which seems to be helpful.

Introduction

While creating a configurable product, you need to create an attribute(s) which will be used as select option(s) for the customer(For Example: Color, Size etc.). These kinda attributes are called super attributes or configurable attributes.

In this article we will be discussing how to get different info about super attributes using raw SQL.

Introduction:

Magento database is based on EAV(Entity Attribute Value) architecture. And it uses this architecture especially for categories, products, customers & customer addresses. Before Magento version 1.4.x it used EAV structure for orders as well but thereafter order’s eav structure has been converted to flat structure.

Similarly you can find attributes for other entities just by using following values for entity_type_code:

catalog_category
customer
customer_address

for categories, customers & customer address respectively.

Note: You can get the related values for entity_type_code from table: eav_entity_type.

Value(V):

Value refers to the actual value of the attribute of the entity. In Magento attribute values of an entity (for example: product) are stored in catalog_product_entity_[backend_type] tables. Where [backend_type] refers to the value of field: backend_type (except value ‘static’) of table: eav_attribute.

Following SQL is used to find all the backend types related to a product entity:

are used for storing values for an attributes of related backend_type.

Note: You must be wondering about backend_type = static. For an attribute with the static backend_type, values are stored as a column directly in the entity table. For example: sku is an attribute of backend_type = static and it’s values are stored in the entity table itself: catalog_product_entity under field: sku.

That’s all about the definition of EAV relating to Magento. Hopefully now you are able to differentiate which attribute values goes where (in which table) based on the backend_type.