Magento2概念与知识点整理-数据库表解析之EAV

Magento使用EAV模式来实现字段的灵活扩展,例如在Customer、产品和分类表中,每个实体的属性和值分散在多个关联表中,便于添加自定义字段。这种模式使得数据分布于多个表,但提供了更大的灵活性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Magento数据库表概述

Magento数据表数量很大,在我们安装的M2各版本中,共大约有近400张左右的Table。
与传统的Mysql建表方式有所不同,Magento为了达到字段方便扩展,结构灵活,在部分业务场中使用了EAV模式的表结构

数据库EAV的含义

1.EAV的理解:Entity-Attribute-Value/(实体-属性-值)

  • 实体:包括要存储的数据类型的信息(客户,产品…)
  • 属性:是实体的属性(颜色,大小,高度…)
  • 值:是给定属性的值(蓝色,红色,…)

也就是说,在我们传统的一张表,以eav的方式实现时,会被横向拆分为多张数据表。
这样做的好处是:可以方便的扩展字段,自定义字段。
如,我们可以在magento的后台,为商品扩展属性字段,并指定该属性的值采用的类型,如text,select下拉,checkbox等。

magento中使用到EAV模式的场景
用户Customer相关的表:

 customer_entity
 customer_entity_datetime       
 customer_entity_decimal
 customer_entity_int 
 customer_entity_text
 customer_entity_varchar

客户地址相关表:

 customer_address_entity
 customer_address_entity_datetime
 customer_address_entity_decimal
 customer_address_entity_int
 customer_address_entity_text
 customer_address_entity_varchar

产品表:

 catalog_product_entity        
 catalog_product_entity_datetime  
 catalog_product_entity_decimal
 catalog_product_entity_gallery 
 catalog_product_entity_int 
 catalog_product_entity_media_gallery  
 catalog_product_entity_media_gallery_value
 catalog_product_entity_media_gallery_value_to_entity 
 catalog_product_entity_media_gallery_value_video 
 catalog_product_entity_text 
 catalog_product_entity_tier_price
 catalog_product_entity_varchar

分类表:

 catalog_category_entity
 catalog_category_entity_datetime
 catalog_category_entity_decimal
 catalog_category_entity_int
 catalog_category_entity_text

实体类型表:

eav_entity_int
eav_entity_varchar
eav_entity_text
eav_entity_decimal
eav_entity_datetime

PS: 我们在平时的开发中,需要对eav有一个大概的了解,这样在具体的业务逻辑中,才能清楚数据分布在了哪些表中。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

金哥铁码

打赏一下,功德+1

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值