问题
By checking sales module's config, there is sales_entity section as below
<models>
<sales>
<class>Mage_Sales_Model</class>
<resourceModel>sales_resource</resourceModel>
</sales>
<sales_entity>
<class>Mage_Sales_Model_Entity</class>
<entities>
<quote>
and those class Mage_Sales_Model_Entity_xxx
extends Mage_Eav_Model_Entity_Abstract
, showing that sales/order is EAV
style but not flat one.
I can also find table "eav_entity_type" have a lot of records related with "order".
But, I go through the code, sadly, EAV
is not at last in place in current codebase (at least v1.7).
Can anyone help to clarify? Is EAV
for sales/order deperecated?
回答1:
In the latest versions of Magento (i.e. 1.6 and 1.7, can't say for earlier) the sales entity attributes are no longer stored in the EAV attribute-value tables. The resource models of the Mage_Sales module connect the sales entities to flat tables.
You can also see that the base Sales model class Mage_Sales_Model_Abstract
extends Mage_Core_Model_Abstract
, and the base Sales resource model Mage_Sales_Model_Resource_Abstract
extends Mage_Core_Model_Resource_Db_Abstract
- neither of those is an EAV model or an EAV resource model.
The attribute-entity metadata that you find in the table eav_entity_type
is similar to the EAV entities of the Catalog and Customer modules, yet the attribute value storage system is not EAV.
I guess, the configuration you encountered is left for the backward compatibility.
I've put together a description of the Magento's EAV system, you may find it interesting: http://www.divisionlab.com/solvingmagento/magento-eav-system/
回答2:
I've compared old Magento versions and found a big difference on Sales Order Model between 2 versions 1.4.0.1 and 1.4.1.0
This file was added to create the sales_flat_order and remove Order EAV tables Mage/Sales/sql/mysql4-upgrade-1.3.99-1.4.0.0.php - Line 1144
// Remove previous tables
$tablesToDrop = array(
'sales_order_entity_decimal',
'sales_order_entity_datetime',
'sales_order_entity_int',
'sales_order_entity_text',
'sales_order_entity_varchar',
'sales_order_entity',
'sales_order_decimal',
'sales_order_datetime',
'sales_order_int',
'sales_order_text',
'sales_order_varchar',
'sales_order'
);
foreach ($tablesToDrop as $table) {
$table = $installer->getTable($table);
if (!$installer->tableExists($table)) {
continue;
}
$installer->getConnection()->query(
'DROP TABLE ' . $installer->getConnection()->quoteIdentifier($table)
);
}
The resource class file Mage_Sales_Model_Mysql4_Order was changed to extends from Mage_Sales_Model_Mysql4_Order_Abstract instead of Mage_Eav_Model_Entity_Abstract
Magento also noted about the changes from EAV to flat sales on this version might be a very heavy operation.
I believe we can't use EAV for the orders as same as products or customers anymore.
来源:https://stackoverflow.com/questions/14622845/is-magento-sales-eav