`
天梯梦
  • 浏览: 13763966 次
  • 性别: Icon_minigender_2
  • 来自: 洛杉矶
社区版块
存档分类
最新评论

magento EAV数据库Magento EAV structure & role of eav_attribute’s backend_type field

 
阅读更多

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.

 

From the defination of EAV:


Entity(E):

Entity actually refers to data item.
In Magento:

catalog_category_entity
catalog_product_entity
customer_entity
customer_address_entity
 

are the entity tables for categories, products, customers & customer addresses respectively.


Attribute(A):

Attribute refers to the different attributes of an Entity.
In Magento, attributes related to an entity are stored in a single table: eav_attribute but differentiated by field: entity_type_id.

 

We can easily find all the attributes related to an entity using the following SQL query(For Example: product):

SELECT
  attribute_code,
  attribute_id,
  backend_type
FROM
  eav_attribute
WHERE entity_type_id =
  (SELECT
    entity_type_id
  FROM
    eav_entity_type
  WHERE entity_type_code = 'catalog_product')
 

Which gives the following results:

+----------------------------+--------------+--------------+
| attribute_code             | attribute_id | backend_type |
+----------------------------+--------------+--------------+
| activation_information     |          496 | text         |
| color                      |          272 | int          |
| color_code                 |          950 | varchar      |
| computer_manufacturers     |          510 | int          |
| contrast_ratio             |          875 | int          |
| cost                       |          100 | decimal      |
| country_orgin              |          507 | text         |
| cpu_speed                  |          877 | int          |
| created_at                 |          930 | static       |
| custom_design              |          571 | varchar      |
| custom_design_from         |          572 | datetime     |
| custom_design_to           |          573 | datetime     |
| custom_layout_update       |          531 | text         |
| description                |           97 | text         |
| dimension                  |          494 | text         |
| enable_googlecheckout      |          903 | int          |
| finish                     |          509 | text         |
| gallery                    |          271 | varchar      |
| gender                     |          501 | int          |
| gift_message_available     |          562 | varchar      |
| harddrive_speed            |          878 | varchar      |
| hardrive                   |          499 | text         |
| has_options                |          838 | static       |
| image                      |          106 | varchar      |
| image_label                |          879 | varchar      |
| in_depth                   |          492 | text         |
| is_imported                |          949 | int          |
| is_recurring               |          933 | int          |
| links_exist                |          947 | int          |
| links_purchased_separately |          904 | int          |
| links_title                |          906 | varchar      |
| manufacturer               |          102 | int          |
| max_resolution             |          873 | varchar      |
| media_gallery              |          703 | varchar      |
| megapixels                 |          513 | int          |
| memory                     |          498 | text         |
| meta_description           |          105 | varchar      |
| meta_keyword               |          104 | text         |
| meta_title                 |          103 | varchar      |
| minimal_price              |          503 | decimal      |
| model                      |          495 | text         |
| name                       |           96 | varchar      |
| news_from_date             |          704 | datetime     |
| news_to_date               |          705 | datetime     |
| old_id                     |          110 | int          |
| options_container          |          836 | varchar      |
| package_id                 |          951 | int          |
| page_layout                |          929 | varchar      |
| price                      |           99 | decimal      |
| price_type                 |          859 | int          |
| price_view                 |          862 | int          |
| processor                  |          497 | text         |
| ram_size                   |          874 | varchar      |
| recurring_profile          |          934 | text         |
| required_options           |          837 | static       |
| response_time              |          876 | varchar      |
| room                       |          508 | int          |
| samples_title              |          905 | varchar      |
| screensize                 |          500 | text         |
| shape                      |          476 | text         |
| shipment_type              |          863 | int          |
| shipping_qty               |          952 | int          |
| shirt_size                 |          525 | int          |
| shoe_size                  |          502 | int          |
| shoe_type                  |          107 | int          |
| short_description          |          506 | text         |
| sku                        |           98 | static       |
| sku_type                   |          860 | int          |
| small_image                |          109 | varchar      |
| small_image_label          |          880 | varchar      |
| special_from_date          |          568 | datetime     |
| special_price              |          567 | decimal      |
| special_to_date            |          569 | datetime     |
| status                     |          273 | int          |
| tax_class_id               |          274 | int          |
| thumbnail                  |          493 | varchar      |
| thumbnail_label            |          881 | varchar      |
| tier_price                 |          270 | decimal      |
| updated_at                 |          931 | static       |
| url_key                    |          481 | varchar      |
| url_path                   |          570 | varchar      |
| visibility                 |          526 | int          |
| weight                     |          101 | decimal      |
| weight_type                |          861 | int          |
+----------------------------+--------------+--------------+
 

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

catalog_category
customer
customer_address
 

or 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:

SELECT DISTINCT
  backend_type
FROM
  eav_attribute
WHERE entity_type_id =
  (SELECT
    entity_type_id
  FROM
    eav_entity_type
  WHERE entity_type_code = 'catalog_product')
 

Which results: 

+--------------+
| backend_type |
+--------------+
| text         |
| int          |
| varchar      |
| decimal      |
| static       |
| datetime     |
+--------------+
 

So tables: 

catalog_product_entity_text
catalog_product_entity_int
catalog_product_entity_varchar
catalog_product_entity_decimal
catalog_product_entity_datetime
 

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.

 

Thanks for reading & Happy E-Commerce!!

 

 

来源:http://www.blog.magepsycho.com/magento-eav-structure-role-of-eav_attributes-backend_type-field/

 

 

 

分享到:
评论

相关推荐

    Magento 1.8版本下eav模型demo

    此代码仅供参考没有后台管理表格1.8版本下可用 ...2.eav_attribute,eav_attribute_group,eav_attribute_set,eav_entity_attribute,eav_entity_type 每个表多一条数据。 作者网站:http://www.sharpmagento.com/

    magento商城数据库

    Magento 商城数据库是一个关键组成部分,它是 Magento 电子商务平台的核心,负责存储所有商品信息、客户数据、订单记录以及网站配置等重要信息。Magento 是一个开源的电子商务解决方案,以其强大的功能和高度可定制...

    magento数据库批量导出产品及自定义属性语句

    自定义属性则存储在`eav_attribute`、`eav_attribute_set`、`eav_entity_type`和`catalog_eav_attribute`等表中。因此,批量导出产品和自定义属性需要联合查询这些表。 `magento导出产品sql.php`可能包含了一个SQL...

    Magento 数据库设计图.pdf

    标题:Magento 数据库设计图 描述:Magento 数据库设计图旨在提供一个清晰的视图,帮助用户理解 Magento 系统内部的数据结构与关联性。通过这张设计图,开发者和DBA能够快速掌握数据库中各表之间的关系,以及它们在...

    magento 数据库 以及时尚模板

    本资源“Magento数据库 以及时尚模板”显然是针对服装类商家,提供了数据库配置和时尚设计的解决方案。 首先,让我们详细探讨Magento数据库的构建和管理。Magento的核心功能之一是其复杂的商品目录系统,这依赖于一...

    magehost_cm_cache_backend:MageHost扩展版的Colin Mollenhour的Cm_Cache_Backend_File和Cm_Cache_Backend_Redis

    MageHost_Cm_Cache_Backend MageHost扩展版的Colin Mollenhour的Cm_Cache_Backend_File和Cm_Cache_Backend_Redis安装安装 cd到您的Magento根目录test -d .modman || modman init modman clone --copy --force ...

    magento数据结构分析

    18. **EAV**, **SALES**, **SYSTEM**:EAV模型、销售模块和系统模块,构成了Magento的核心架构。 19. **MAGENTO-DatabaseDiagram[v1.1.6]**:这是Magento数据库结构的版本化图表,展示了数据库的完整设计。 20. **...

    magento产品名称及描述批量修改sql

    SELECT attribute_id FROM eav_attribute WHERE entity_type_id = 4 AND frontend_label LIKE '%产品名称%' OR frontend_label LIKE '%产品描述%'; ``` 2. **构建UPDATE语句**:使用找到的`attribute_id`,构造...

    magento导入数据库

    当涉及到Magento站点的迁移时,一个常见的方法是通过使用PHPMyAdmin来导入数据库,这种方法不仅高效,而且能够确保数据的完整性和一致性。下面,我们将深入探讨Magento通过PHPMyAdmin方式做站点迁移的具体步骤、注意...

    magento2-attribute-description:Magento 2模块,用于向产品属性添加描述

    Magento 2的Dmatthew_AttributeDescription模块这是一个Magento 2模块,它增加了向产品属性添加描述的功能。 将描述添加到可配置属性,并将其显示在您的产品视图页面上。 使用属性描述可以帮助向客户解释复杂的属性...

    zencart 数据迁移到magento 数据库操作

    在电子商务领域,商家可能会面临更换电商平台的情况,例如从ZenCart迁移到Magento。这两个都是流行的开源购物车系统,但Magento提供了更多的功能和扩展性。本文将详细介绍如何进行Zencart到Magento的数据迁移,尤其...

    Magento数据库设计

    Magento是一个功能强大的开源电子商务解决方案,由于其庞大的功能集合和灵活的架构,其数据库设计相对复杂。Magento数据库包含超过250张表,每张表都承载了不同模块和功能的数据存储和业务逻辑。这些表之间存在大量...

    magento二次开发大全

    2. **EAV模型**:Entity-Attribute-Value(EAV)模型是Magento数据存储的关键特性,允许存储具有动态属性的商品信息。`EAV(E-V图 product为例).png`和`EAV模型.png`可能展示了如何通过EAV结构存储和检索商品数据。 ...

    magento快速复制网站_magento_magento快速复制站_

    Magento是一款强大的开源电子商务...总之,快速复制Magento站点涉及多个层面的工作,包括数据库迁移、文件复制、配置调整和缓存处理。正确执行这些步骤将帮助你高效地在新环境中搭建起一个与原站点相似的Magento商店。

    Cm_Cache_Backend_File:改进了Zend_Cache_Backend_File的替代品-与Magento完美搭配!

    Cm_Cache_Backend_File 可用的Zend_Cache_Backend_File后端在使用标签进行清理时性能极差,这使得随着缓存项目数量的增加,后端变得不可用。 该后端进行了许多更改,从而极大地提高了性能,尤其是在标签清洗方面。 ...

    magento certified developer 认证 题库

    **解释**:在Magento系统中,加载产品属性需要满足两个关键条件:首先,属性的基本信息需存储在eav_attribute表中,包括属性的特性和所属的实体类型;其次,此属性应属于当前加载产品的属性集,确保其与特定产品的...

    Rubic_Cache_Backend_Aerospike:Magento 的 Aerospike 缓存后端

    Rubic_Cache_Backend_Aerospike 这是什么? Magento 缓存后端,用于名为的内存中 NoSQL 数据库。 为什么? Aerospike 真的很容易横向扩展(与 Redis Clustering 相比)。 它也真的。 数据性感的。 为了乐趣和...

    magento事件清单

    #### 2.9 `adminhtml_product_attribute_types` #### 2.10 `adminhtml_catalog_product_edit_prepare_form` #### 2.11 `adminhtml_catalog_product_edit_element_types` 这些事件主要涉及产品属性和编辑表单的准备...

    Magento2.1.13汉化

    Magento 2.1.13汉化包是一个针对Magento电子商务平台的中文本地化解决方案,它使得在中国使用Magento的商家和开发者能够更方便地理解和操作这个强大的开源系统。Magento是一款广泛使用的开源电商框架,以其高度可...

    Magento2-Data-Migration:此脚本将您的 Magento1 数据库迁移到 Magento2

    Magento 2 数据库迁移将数据库从 Magento 1.8、1.9 迁移到 Magento 2 beta5。 该程序绝对没有任何保证。 对于每个新的 Magento2 发行版/预发行版,必须调整此模块,主要是在有新的安装脚本时。 此外,Magento2 将...

Global site tag (gtag.js) - Google Analytics