magento mysql4-install_MAGENTO与表,数据字段的对应关系
配置文件在數(shù)據(jù)庫中的反應(yīng)
CONFIG.xml與SETUP
Setup 在數(shù)據(jù)庫的處理流程
I'm going to stop right here to explain how/when the setup scripts are run:
The setup script mechanism is run the FIRST time a request is made after the cache is cleared.
o Magento will get a collection of all the "setup resources" and their corresponding Module version numbers from the config.xml files.
o Magento will then go to the core_resource table and get a collection of all the "setup resources" and their version numbers stored in the table.
o Magento will then do 1 of 3 things:
o If the setup resource doesn't exist in the core_resource table it will run an install script.
o If the resource version in the database is less than the one in the config.xml file, it will run one to many update scripts.
o If the resource version in the database is greater than the one in the config.xml file, it will run a rollback script.
mysql4-upgrade與mysql4-install
各種EAV的Entity與屬性
MAGENTO與EAV的設(shè)計與應(yīng)用,主要包如下的幾個方面: EAV設(shè)計在數(shù)據(jù)庫中的反映;
對entity 對象的查詢,單個實體對象的查找,entity實體對象的修改,添加,刪除操作;
新建一個新的entity.
EAV設(shè)計或者是entity實體在數(shù)據(jù)庫中的反映:
EAV設(shè)計或者對實體的操作大多是通過封裝方法或者是配置來實現(xiàn)的,而非單純的SQL語句。這樣做的好處是操作更加簡單,但是所產(chǎn)生的問題就在于配置出現(xiàn)問題導(dǎo)致調(diào)試非常麻煩。
針對setup與resource(即module中所必須定義的resource)
in the config.xml we need to define the resources. The one we really care about here is the "setup" resource.Remember the name "awesome_setup" and notice the module element inside of it. The module is the "driver" for the setup scripts. If the module's version number changes, it will look for scripts to run.
如:
1: 2: ...3: 4: 5: 6: Super_Awesome7: 8: 9: core_setup10: 11: 12: 13: 14: core_write15: 16: 17: 18: 19: core_read20: 21: 22: 23:
install與upgrade SQL腳本
Magento will then do 1 of 3 things:
SQL INSTALL? & CORE_RESOURCE: If the setup resource doesn't exist in the core_resource table it will run an install script,并且將setup resource 插入到core_resource表中。
SQL UPGRADE: If the resource version in the database is less than the one in the config.xml file, it will run one to many update scripts.
If the resource version in the database is greater than the one in the config.xml file, it will run a rollback script.
針對自定義attribute的關(guān)鍵表:
在EAV實體設(shè)計中,是可以自行添加attribute,而非重新新建字段等。使用EAV來添加屬性。其中的方法包括:
addAttribute(),removeAttribute(),upgradeAttribute().
如;
1: $setup->addAttribute('customer', 'school', array(2: 'type' => 'int',3: 'input' => 'select',4: 'label' => 'School',5: 'global' => 1,6: 'visible' => 1,7: 'required' => 0,8: 'user_defined' => 1,9: 'default' => '0',10: 'visible_on_front' => 1,11: 'source'=> 'profile/entity_school',12: ));
其中對于屬性處理,所涉及到的關(guān)鍵公用表[也就是說任何的一個實體自定義屬性都會添加或者修改數(shù)據(jù)在這三張表中]:
eav_entity_type
eav_attribute
eav_entity_attribute
entity與form
eav_form_element
eav_form_type :? 所有處理entity的form
eav_form_type_entity: entity與entity type 之間的關(guān)聯(lián)。如customer涉及到哪些form操作等
eav_entity_type: 記錄所有entity實體對象的關(guān)鍵配置信息
關(guān)鍵字段
entity_type_id:實體對象的ID值,與多個表有著關(guān)聯(lián)關(guān)系,特別是eav_attribute,使用entity_type_id,可以知道該實體對象所有的屬性(包括MAGENTO默認的系統(tǒng)屬性以及customize的屬性值)
entity_type_code:實體標識
entity_model:ORM的結(jié)果, 可使用getmodel()來實例化model,進而調(diào)用model所定義的方法。
entity_table:實體所對應(yīng)的最關(guān)鍵表
eav_attribute表
關(guān)鍵字段
attribute_code:屬性所對應(yīng)的關(guān)鍵標識。
attribute_id: 屬性的ID值
其它的字段信息,直接與addAttribute()所添加的信息保持一致。
也就是說如果添加或者是刪除了某一個實體對象,它會直接反映在eav_entity_type表中。
First entry it made in the eav_attribute table
1: INSERT INTO `eav_attribute` (2: `attribute_id` ,3: `entity_type_id` ,4: `attribute_code` ,5: `attribute_model` ,6: `backend_model` ,7: `backend_type` ,8: `backend_table` ,9: `frontend_model` ,10: `frontend_input` ,11: `frontend_label` ,12: `frontend_class` ,13: `source_model` ,14: `is_required` ,15: `is_user_defined` ,16: `default_value` ,17: `is_unique` ,18: `note`19: )20: VALUES (21: NULL , '1', 'school', NULL , NULL , 'int', NULL , NULL , 'select', 'School', NULL , 'profile/entity_school', '1', '0', '0', '0', ''22: );
After insert query, the attribute generated is my case is 121. Next this attribute needs to be associated to an attribute set, the sql for this is
1: INSERT INTO `eav_entity_attribute` (2: `entity_attribute_id` ,3: `entity_type_id` ,4: `attribute_set_id` ,5: `attribute_group_id` ,6: `attribute_id` ,7: `sort_order`8: )9: VALUES (10: NULL , '1', '1', '1', '121', '0'11: );12: The sort_order value in this table, specifies where the attribute will show in admin.
針對單個entity attribute的數(shù)據(jù)表:
customer:
customer_eav_attribute:定義website_id,is_visible,is_required 等
customer_eav_attribute_website:If your using multiple store, you need to make an entry in customer_eav_attribute_website as well
customer_form_attribute: 屬性出現(xiàn),設(shè)置在哪些form中,比如說注冊,修改用戶信息等
Next we need to make entry in a table “customer_eav_attribute”
1: INSERT INTO `customer_eav_attribute` (2: `attribute_id` ,3: `is_visible` ,4: `input_filter` ,5: `multiline_count` ,6: `validate_rules` ,7: `is_system` ,8: `sort_order` ,9: `data_model`10: )11: VALUES (12: '121', '1', NULL , '1', NULL , '0', '0', NULL13: );
If your using multiple store, you need to make an entry in customer_eav_attribute_website as well, but this entry is not compulsary
1: INSERT INTO `customer_eav_attribute_website` (2: `attribute_id` ,3: `website_id` ,4: `is_visible` ,5: `is_required` ,6: `default_value` ,7: `multiline_count`8: )9: VALUES (10: '121', '0', '1', '0', NULL , NULL11: );
Next we need to make entry in a table called “customer_form_attribute”
1: INSERT INTO `customer_form_attribute` (2: `form_code` ,3: `attribute_id`4: )5: VALUES (6: 'adminhtml_customer', '121'7: ), (8: 'checkout_register', '121'9: ), (10: 'customer_account_create', '121'11: ), (12: 'customer_account_edit', '121'13: )14: ;
customer_address
bill
MAGENTO系統(tǒng)預(yù)定義的實體對象:
商品模塊
Catalog(商品類)
catalog_category
catalog_product
用戶模塊
customer(用戶)
customer
customer_address (集中表現(xiàn)在bill)
銷售模塊
creditmemo(支付)
creditmemo
creditmemo_comment
creditmemo_item
Invoice(發(fā)票)
? invoice_comment
? invoice_item
? invoice_payment
Order(訂單)
? order_address
? order_item
? order_payment
? order_status_history
Quote(銷售單據(jù)憑證)
? quote_address
? quote_address_item
? quote_address_rate
? quote_item
? quote_payment
運輸模塊
Shipment(運輸模塊)
? shipment_comment
? shipment_item
? shipment_track
KIPS:所有的實體model都會自動的做set與get. 具體的所使用到的set與get可以參考:http://docs.magentocommerce.com
Global Tag
Adminhtml Tag
Frontend Tag
Default Tag
The default tag allows you to specify any set of config variables needed for yourmodule. The values are normally obtained with getStoreConfig, passing the name of your XML tags as a slash separated string. For better organization of these ad-hoc variables? it is customary to wrap all of your settings in a tag that matches your modu’les? name. The values in the default tag can be overwritten on the configuration page
of the administrative back-end. Any changes to the defaults are inserted into the database table core_config_data. Thesemodified values are still retrieved with a call to getStoreConfig.
entity attribute 在數(shù)據(jù)庫中的反應(yīng)
為product? catelog 添加 Attribute ,
為不同的Entity 添加Attribute
訂單表
sales_flat_order
sales_flat_order_address
sales_flat_order_item
coupon 表
salesrule_coupon? 存儲所有的coupon code
salesrule_coupon_usage? 使用情況
總結(jié)
以上是生活随笔為你收集整理的magento mysql4-install_MAGENTO与表,数据字段的对应关系的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: DOS环境
- 下一篇: linux cmake编译源码,linu