Magento数据库:发票项目数据库表?

Rel*_*lja 2 database magento

有谁知道发票数据在Magento数据库中的存储位置?

例如,我发现订单数据存储在sales_order,sales_flat_order,sales_flat_order_item中.

我还发现主要发票数据存储在sales_order_entity,sales_order_entity_decimal和sales_order_entity_int中.通过这个,我可以更改系统中发票的小计和总计.

但!我不知道在哪里找到物品数据?对于订单,该数据在sales_flat_order_item中,但我的sales_flat_invoice_item表是空的?!

http://img809.imageshack.us/img809/1921/invoicey.jpg

sbd*_*o85 7

我会告诉你我对1.4.0.1的了解,这是我目前开发的版本,对于你使用的任何版本,它可能会也可能不一样.

另外,为什么你还在数据库中呢?Magento已经为您制作了模型,因此您无需在数据库中工作.无论我如何描述我如何找到我正在寻找的属性......

对于初学者,我假设您已经通过mysql客户端登录到数据库,运行

SELECT `entity_type_id`,`entity_type_code`,`entity_table` FROM `eav_entity_type`
Run Code Online (Sandbox Code Playgroud)

这会让你得到像......

+----------------+----------------------+----------------------------------+
| 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               |
+----------------+----------------------+----------------------------------+
Run Code Online (Sandbox Code Playgroud)

我们想要了解有关"invoice_item"实体的更多信息,以便让我们看看它有哪些属性...运行

SELECT `attribute_id`,`entity_type_id`,`attribute_code`,`backend_type` FROM `eav_attribute` WHERE `entity_type_id`=17;
Run Code Online (Sandbox Code Playgroud)

你会得到像......

+--------------+----------------+----------------------------------+--------------+
| 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      |
+--------------+----------------+----------------------------------+--------------+
Run Code Online (Sandbox Code Playgroud)

最后一列(backend_type)与实体(entity_table)的表相结合,该实体的属性将是这样的属性"additional_data"应该在sales_order_entity_text中,attribute_id为349.

有了这些信息,现在我们只需要找一张发票,我将使用我的测试安装中的一个例子.让我们查找发票项目的"base_price".

首先让我们找到与发票关联的所有项目(在我的情况下,发票entity_id为1303954)

SELECT * FROM `sales_order_entity` WHERE `entity_type_id`=17 AND `parent_id`=1303954;
Run Code Online (Sandbox Code Playgroud)

这给了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 |
+-----------+----------------+------------------+--------------+-----------+----------+---------------------+---------------------+-----------+
Run Code Online (Sandbox Code Playgroud)

让我们选择第一个并找到'base_price'

SELECT * FROM `sales_order_entity_decimal` WHERE `attribute_id`=345 AND `entity_id`=1303955;
Run Code Online (Sandbox Code Playgroud)

这给了我们......

+----------+----------------+--------------+-----------+---------+
| value_id | entity_type_id | attribute_id | entity_id | value   |
+----------+----------------+--------------+-----------+---------+
|  7361390 |             17 |          345 |   1303955 | 31.2500 |
+----------+----------------+--------------+-----------+---------+
Run Code Online (Sandbox Code Playgroud)

当然这只是一个简单的更新来改变它.

再次,如果你可以通过Magento模型做到这一点,我强烈建议你这样做,但如果手动是唯一的方式,那么我希望这有帮助:)