Magento多属性可配置商品数据原理解析
来源:互联网 发布:mac怎么换管理员 编辑:程序博客网 时间:2024/05/15 08:44
多属性商品在网店中很通用,比如买衣服需要选择颜色和尺码,而且不同的颜色和尺码卖家可以根据库存情况进行打折促销,对于没有库存的商品,则无法选择等。本文分析在Magento系统中增加一个多属性可选择的商品的原理。
在magento系统中设置可配置商品分为4个步骤:
1.设置可配置的属性。
2.设置包含可配置的属性集。
3.添加可配置商品。
4.在可配置商品中增加基于不同属性的Simple Product。
1.在Magento后台添加一条可配置属性,会在catalog_eav_attribute表中增加一条记录。可配置属性需要设置为global,并将值设为必须要求,在前端的显示为Dropdown,应用于Simple Product和Configurable Product两种。
INSERT INTO `catalog_eav_attribute` (`attribute_id`, `frontend_input_renderer`, `is_global`, `is_visible`, `is_searchable`, `is_filterable`, `is_comparable`, `is_visible_on_front`, `is_html_allowed_on_front`, `is_used_for_price_rules`, `is_filterable_in_search`, `used_in_product_listing`, `used_for_sort_by`, `is_configurable`, `apply_to`, `is_visible_in_advanced_search`, `position`, `is_wysiwyg_enabled`, `is_used_for_promo_rules`) VALUES (947, NULL, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, ‘simple,configurable’, 0, 0, 0, 0);
同时在eav_attribute表中也会增加一条记录。
INSERT INTO `eav_attribute` (`attribute_id`, `entity_type_id`, `attribute_code`, `attribute_model`, `backend_model`, `backend_type`, `backend_table`, `frontend_model`, `frontend_input`, `frontend_label`, `frontend_class`, `source_model`, `is_required`, `is_user_defined`, `default_value`, `is_unique`, `note`) VALUES (947, 10, ‘chima’, NULL, NULL, ‘int’, NULL, NULL, ‘select’, ‘chima’, NULL, ‘eav/entity_attribute_source_table’, 1, 1, ”, 0, ”);
对于在可配置属性中多种语言,相关多种语言的文字会存储在eav_attribute_label表中。其中store_id可以指定一种语言类型。
INSERT INTO `eav_attribute_label` (`attribute_label_id`, `attribute_id`, `store_id`, `value`) VALUES (12, 947, 4, ‘尺码’);
可选择的属性值会存储在eav_attribute_option表中,有几个可选项就有几条记录。
INSERT INTO `eav_attribute_option` (`option_id`, `attribute_id`, `sort_order`) VALUES (129, 947, 0),(130, 947, 0),(131, 947, 0);
对于属性值也是多语言的,因此标签多语言存储在eav_attribute_option_value表中。
INSERT INTO `eav_attribute_option_value` (`value_id`, `option_id`, `store_id`, `value`) VALUES(1505, 129, 0, ’37 inch’),(1506, 129, 4, ’37码’),(1507, 130, 0, ’36 inch’),(1508, 130, 4, ’36码’),(1509, 131, 0, ’35 inch’),(1510, 131, 4, ’35码’);
为了后面的解析,我们再建一条属性板式banshi。
2.在Magento系统中增加一条属性集,基于default属性集,并加入新建的chima和banshi属性。保存后,系统首先会在eav_attribute_set表中增加一条记录。
INSERT INTO `eav_attribute_set` (`attribute_set_id`, `entity_type_id`, `attribute_set_name`, `sort_order`) VALUES(64, 10, ‘yifu’, 0);
在eav_entity_attribute表中描述该属性集和所有属性的对应关系。
INSERT INTO `eav_entity_attribute` (`entity_attribute_id`, `entity_type_id`, `attribute_set_id`, `attribute_group_id`, `attribute_id`, `sort_order`) VALUES
(4846, 10, 63, 188, 934, 2),
(4862, 10, 64, 189, 110, 15),
(4870, 10, 64, 189, 570, 21),
(4876, 10, 64, 189, 706, 24),
(4878, 10, 64, 189, 837, 25),
(4880, 10, 64, 189, 838, 26),
(4882, 10, 64, 189, 859, 27),
(4884, 10, 64, 189, 860, 28),
(4886, 10, 64, 189, 861, 29),
(4888, 10, 64, 189, 863, 30),
(4890, 10, 64, 189, 879, 31),
(4892, 10, 64, 189, 880, 32),
(4894, 10, 64, 189, 881, 33),
(4896, 10, 64, 189, 904, 34),
(4898, 10, 64, 189, 905, 35),
(4900, 10, 64, 189, 906, 36),
(4902, 10, 64, 189, 930, 37),
(4904, 10, 64, 189, 931, 38),
(4906, 10, 64, 189, 944, 39),
(4910, 10, 64, 190, 503, 1),
(4962, 10, 64, 189, 96, 1),
(4964, 10, 64, 189, 98, 2),
(4966, 10, 64, 189, 101, 3),
(4968, 10, 64, 189, 102, 9),
(4970, 10, 64, 189, 272, 10),
(4972, 10, 64, 189, 273, 4),
(4974, 10, 64, 189, 274, 5),
(4976, 10, 64, 189, 481, 6),
(4978, 10, 64, 189, 526, 7),
(4980, 10, 64, 189, 562, 8),
(4982, 10, 64, 189, 704, 11),
(4984, 10, 64, 189, 705, 12),
(4986, 10, 64, 189, 947, 13),
(4988, 10, 64, 189, 948, 14),
(4990, 10, 64, 190, 99, 1),
(4992, 10, 64, 190, 100, 2),
(4994, 10, 64, 190, 270, 3),
(4996, 10, 64, 190, 567, 4),
(4998, 10, 64, 190, 568, 5),
(5000, 10, 64, 190, 569, 6),
(5002, 10, 64, 190, 862, 7),
(5004, 10, 64, 190, 903, 8),
(5006, 10, 64, 191, 103, 1),
(5008, 10, 64, 191, 104, 2),
(5010, 10, 64, 191, 105, 3),
(5012, 10, 64, 192, 106, 4),
(5014, 10, 64, 192, 109, 2),
(5016, 10, 64, 192, 271, 3),
(5018, 10, 64, 192, 493, 1),
(5020, 10, 64, 192, 703, 5),
(5022, 10, 64, 193, 97, 1),
(5024, 10, 64, 193, 506, 2),
(5026, 10, 64, 194, 531, 4),
(5028, 10, 64, 194, 571, 1),
(5030, 10, 64, 194, 572, 2),
(5032, 10, 64, 194, 573, 3),
(5034, 10, 64, 194, 836, 5),
(5036, 10, 64, 194, 929, 6),
(5038, 10, 64, 195, 933, 1),
(5040, 10, 64, 195, 934, 2);
其中Group表示属性分组,一般有General、Price等组,每个组下有一些属性,目的是让用户在后台添加商品属性的时候可以分栏目种类,避免一长条下来混淆不清。
INSERT INTO `eav_attribute_group` (`attribute_group_id`, `attribute_set_id`, `attribute_group_name`, `sort_order`, `default_id`) VALUES
(189, 64, ‘General’, 1, 1),
(190, 64, ‘Prices’, 2, 0),
(191, 64, ‘Meta Information’, 3, 0),
(192, 64, ‘Images’, 4, 0),
(193, 64, ‘Description’, 5, 0),
(194, 64, ‘Design’, 6, 0),
(195, 64, ‘Recurring Profile’, 7, 0);
3.创建一个configurable商品,选择属性集为刚创建的yifu,类型选择configrable product,然后设置属性,在库存项里面,不能设置具体的数量,因为可配置的商品的库存只对应它所关联的sku的具体商品的库存。
首先在catalog_product_entity增加一条记录。
INSERT INTO `catalog_product_entity` (`entity_id`, `entity_type_id`, `attribute_set_id`, `type_id`, `sku`, `created_at`, `updated_at`, `has_options`, `required_options`) VALUES(180, 10, 64, ‘configurable’, ‘weiyisku’, ’2013-02-26 06:45:55′, ’2013-02-26 06:45:55′, 0, 0);
其他各项常规属性记录在catalog_product_entity_datetime、catalog_product_entity_decimal、catalog_product_entity_int、catalog_product_entity_text、catalog_product_entity_varchar五个表中。
4.增加可配置商品下面的关联商品,不同的sku不同的属性。系统会在后台生成几个simple product简单商品,记录在catalog_product_entity表中,属性记录在catalog_product_entity_datetime、catalog_product_entity_decimal、catalog_product_entity_int、catalog_product_entity_text、catalog_product_entity_varchar五个表中。
在catalog_product_relation表中增加可配置商品和简单商品的关系。
INSERT INTO `catalog_product_relation` (`parent_id`, `child_id`) VALUES(180, 181),(180, 182),(180, 183);
- Magento多属性可配置商品数据原理解析
- Magento通过可配置(configurable)商品Id获得子类Ids
- Magento 布局(XML)原理解析
- magento Layout布局原理解析
- magento -- 如何为商品分类(category)添加自定义属性
- magento -- 如何获得某个属性组的所有商品
- magento -- 如何为商品分类(category)添加自定义属性
- magento 更新所有商品属性,提交只能保存1000个
- magento 属性与属性集配置attributes
- 目录管理之可配置商品
- 淘宝、亚马逊、京东商城、Magento系统在商品多属性、多价格、多语言、多库存、多供应商研究
- magento 判断是否为可配置产品
- magento 商品价钱管理
- magento 商品列表排序
- Magento获取商品CategoryIds
- android商品属性选择标签控件,可实现自动换行
- 商品多属性选择效果
- 商品多属性筛选案例
- django coercing to Unicode: need string or buffer, long found
- Eclipse导入Hadoop源码项目
- Oracle存储过程创建及调用
- 我的SEO之路2013年3月15日关于个人博客关键字排名50.
- 也谈VS2010非托管c++访问webservice服务
- Magento多属性可配置商品数据原理解析
- Oracle语法温故(字符串相关函数、数值相关函数、单行函数、多行函数)
- Spring FactoryBean
- Linux 64位C编程过程中的注意点
- SimpleJDBCOperator 增删改查操作
- mysql一句话导出shell
- 淘宝、亚马逊、京东商城、Magento系统在商品多属性、多价格、多语言、多库存、多供应商研究
- C # winform基础
- 实现 托动PageControl上的标签页