我會告訴你我所知道的1.4.0.1這是我目前開發的版本,它可能會或可能不會對任何版本使用的是相同的。
另外,爲什麼你在數據庫呢? Magento已經爲您製作模型,以便您在數據庫中使用而不是。不管我將描述我是如何找到我要找的......任何屬性
對於初學者我假設你已經登錄到通過mysql客戶端數據庫,運行
SELECT `entity_type_id`,`entity_type_code`,`entity_table` FROM `eav_entity_type`
這將讓你像...
+----------------+----------------------+----------------------------------+
| entity_type_id | entity_type_code | entity_table |
+----------------+----------------------+----------------------------------+
| 1 | customer | customer/entity |
| 2 | customer_address | customer/address_entity |
| 3 | catalog_category | catalog/category |
| 4 | catalog_product | catalog/product |
| 5 | quote | sales/quote |
| 6 | quote_item | sales/quote_item |
| 7 | quote_address | sales/quote_address |
| 8 | quote_address_item | sales/quote_entity |
| 9 | quote_address_rate | sales/quote_entity |
| 10 | quote_payment | sales/quote_entity |
| 11 | order | sales/order |
| 12 | order_address | sales/order_entity |
| 13 | order_item | sales/order_entity |
| 14 | order_payment | sales/order_entity |
| 15 | order_status_history | sales/order_entity |
| 16 | invoice | sales/order_entity |
| 17 | invoice_item | sales/order_entity |
| 18 | invoice_comment | sales/order_entity |
| 19 | shipment | sales/order_entity |
| 20 | shipment_item | sales/order_entity |
| 21 | shipment_comment | sales/order_entity |
| 22 | shipment_track | sales/order_entity |
| 23 | creditmemo | sales/order_entity |
| 24 | creditmemo_item | sales/order_entity |
| 25 | creditmemo_comment | sales/order_entity |
+----------------+----------------------+----------------------------------+
我們想知道更多關於「invoice_item」實體,以便讓我們看看它有什麼屬性...運行
SELECT `attribute_id`,`entity_type_id`,`attribute_code`,`backend_type` FROM `eav_attribute` WHERE `entity_type_id`=17;
,你會得到像...
+--------------+----------------+----------------------------------+--------------+
| attribute_id | entity_type_id | attribute_code | backend_type |
+--------------+----------------+----------------------------------+--------------+
| 349 | 17 | additional_data | text |
| 340 | 17 | base_cost | decimal |
| 346 | 17 | base_discount_amount | decimal |
| 345 | 17 | base_price | decimal |
| 679 | 17 | base_price_incl_tax | decimal |
| 348 | 17 | base_row_total | decimal |
| 681 | 17 | base_row_total_incl_tax | decimal |
| 347 | 17 | base_tax_amount | decimal |
| 567 | 17 | base_weee_tax_applied_amount | decimal |
| 568 | 17 | base_weee_tax_applied_row_amount | decimal |
| 579 | 17 | base_weee_tax_disposition | decimal |
| 580 | 17 | base_weee_tax_row_disposition | decimal |
| 337 | 17 | description | text |
| 342 | 17 | discount_amount | decimal |
| 336 | 17 | name | varchar |
| 334 | 17 | order_item_id | int |
| 333 | 17 | parent_id | static |
| 341 | 17 | price | decimal |
| 678 | 17 | price_incl_tax | decimal |
| 335 | 17 | product_id | int |
| 339 | 17 | qty | decimal |
| 344 | 17 | row_total | decimal |
| 680 | 17 | row_total_incl_tax | decimal |
| 338 | 17 | sku | varchar |
| 343 | 17 | tax_amount | decimal |
| 571 | 17 | weee_tax_applied | text |
| 569 | 17 | weee_tax_applied_amount | decimal |
| 570 | 17 | weee_tax_applied_row_amount | decimal |
| 577 | 17 | weee_tax_disposition | decimal |
| 578 | 17 | weee_tax_row_disposition | decimal |
+--------------+----------------+----------------------------------+--------------+
最後一列(backend_type)與表的實體(entity_table)聯合進行,其中該實體的屬性會因此屬性「additional_data」應該在sales_order_entity_text中,其attribute_id爲349.
掌握了這些信息,現在我們只需要找到一張發票,我將使用我的一個測試安裝示例。讓我們查找發票項目的「base_price」。
首先讓我們找到了關聯到發票的所有項目(在我的1303954情況下發票ENTITY_ID)
SELECT * FROM `sales_order_entity` WHERE `entity_type_id`=17 AND `parent_id`=1303954;
這使2項
+-----------+----------------+------------------+--------------+-----------+----------+---------------------+---------------------+-----------+
| entity_id | entity_type_id | attribute_set_id | increment_id | parent_id | store_id | created_at | updated_at | is_active |
+-----------+----------------+------------------+--------------+-----------+----------+---------------------+---------------------+-----------+
| 1303955 | 17 | 0 | | 1303954 | NULL | 2011-06-01 14:10:48 | 2011-06-01 14:10:48 | 1 |
| 1303956 | 17 | 0 | | 1303954 | NULL | 2011-06-01 14:10:48 | 2011-06-01 14:10:48 | 1 |
+-----------+----------------+------------------+--------------+-----------+----------+---------------------+---------------------+-----------+
讓我們選擇第一個找到在 'BASE_PRICE'
SELECT * FROM `sales_order_entity_decimal` WHERE `attribute_id`=345 AND `entity_id`=1303955;
這給了我們....
+----------+----------------+--------------+-----------+---------+
| value_id | entity_type_id | attribute_id | entity_id | value |
+----------+----------------+--------------+-----------+---------+
| 7361390 | 17 | 345 | 1303955 | 31.2500 |
+----------+----------------+--------------+-----------+---------+
當然它只是一個簡單的更新來改變它。
同樣,如果你可以通過Magento的模型,我會強烈建議你這樣做的,但這樣做,如果是手動去那麼好,我希望這有助於:)
你的Magento的版本將改變的唯一途徑對這個問題的答案是實質性的。 – 2011-06-01 15:48:27