Skip to content

Commit

Permalink
Make oldFields mapping hardcoded to speed up system
Browse files Browse the repository at this point in the history
The mapping came with Magneto 1.6 to provide a backward compatibility
for old (pre 1.6) db field names.
Now the mapping is hardcoded in the class instead of saved
in the configuration.
This improves performance as Magento will not create tons of objects for
every new product/order/... entities.

Related: #920
  • Loading branch information
tmotyl committed Jun 6, 2022
1 parent ae2520c commit aa16d98
Show file tree
Hide file tree
Showing 15 changed files with 19 additions and 30 deletions.
1 change: 0 additions & 1 deletion app/code/core/Mage/Catalog/Model/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,6 @@ protected function _construct()
*/
protected function _initOldFieldsMap()
{
$this->_oldFieldsMap = Mage::helper('catalog')->getOldFieldMap();
return $this;
}

Expand Down
1 change: 1 addition & 0 deletions app/code/core/Mage/CatalogInventory/Model/Stock/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ protected function _construct()
*/
protected function _initOldFieldsMap()
{
// pre 1.6 fields names, old => new
$this->_oldFieldsMap = array(
'stock_status_changed_automatically' => 'stock_status_changed_auto',
'use_config_enable_qty_increments' => 'use_config_enable_qty_inc'
Expand Down
7 changes: 6 additions & 1 deletion app/code/core/Mage/Sales/Model/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,12 @@ protected function _construct()
*/
protected function _initOldFieldsMap()
{
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order');
// pre 1.6 fields names, old => new
$this->_oldFieldsMap = [
'payment_authorization_expiration' => 'payment_auth_expiration',
'forced_do_shipment_with_invoice' => 'forced_shipment_with_invoice',
'base_shipping_hidden_tax_amount' => 'base_shipping_hidden_tax_amnt',
];
return $this;
}

Expand Down
1 change: 0 additions & 1 deletion app/code/core/Mage/Sales/Model/Order/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ protected function _construct()
*/
protected function _initOldFieldsMap()
{
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order_address');
return $this;
}

Expand Down
1 change: 0 additions & 1 deletion app/code/core/Mage/Sales/Model/Order/Creditmemo.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ protected function _construct()
*/
protected function _initOldFieldsMap()
{
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order_creditmemo');
return $this;
}

Expand Down
5 changes: 4 additions & 1 deletion app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ public function setCreditmemo(Mage_Sales_Model_Order_Creditmemo $creditmemo)
*/
protected function _initOldFieldsMap()
{
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('creditmemo_item');
// pre 1.6 fields names, old => new
$this->_oldFieldsMap = [
'base_weee_tax_applied_row_amount' => 'base_weee_tax_applied_row_amnt',
];
return $this;
}

Expand Down
1 change: 0 additions & 1 deletion app/code/core/Mage/Sales/Model/Order/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ protected function _construct()
*/
protected function _initOldFieldsMap()
{
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order_invoice');
return $this;
}

Expand Down
5 changes: 4 additions & 1 deletion app/code/core/Mage/Sales/Model/Order/Invoice/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ public function _construct()
*/
protected function _initOldFieldsMap()
{
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('invoice_item');
// pre 1.6 fields names, old => new
$this->_oldFieldsMap = [
'base_weee_tax_applied_row_amount' => 'base_weee_tax_applied_row_amnt',
];
return $this;
}
/**
Expand Down
5 changes: 4 additions & 1 deletion app/code/core/Mage/Sales/Model/Order/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ protected function _construct()
*/
protected function _initOldFieldsMap()
{
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order_item');
// pre 1.6 fields names, old => new
$this->_oldFieldsMap = [
'base_weee_tax_applied_row_amount' => 'base_weee_tax_applied_row_amnt',
];
return $this;
}

Expand Down
1 change: 0 additions & 1 deletion app/code/core/Mage/Sales/Model/Order/Shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ protected function _construct()
*/
protected function _initOldFieldsMap()
{
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order_shipment');
return $this;
}

Expand Down
1 change: 0 additions & 1 deletion app/code/core/Mage/Sales/Model/Quote.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ protected function _construct()
*/
protected function _initOldFieldsMap()
{
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('quote');
return $this;
}

Expand Down
1 change: 0 additions & 1 deletion app/code/core/Mage/Sales/Model/Quote/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ protected function _construct()
*/
protected function _initOldFieldsMap()
{
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('quote_address');
return $this;
}

Expand Down
1 change: 0 additions & 1 deletion app/code/core/Mage/Sales/Model/Quote/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ protected function _construct()
*/
protected function _initOldFieldsMap()
{
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('quote_item');
return $this;
}

Expand Down
7 changes: 0 additions & 7 deletions app/code/core/Mage/Sales/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1198,13 +1198,6 @@
</product>
</catalog>
<sales>
<old_fields_map>
<order>
<payment_authorization_expiration>payment_auth_expiration</payment_authorization_expiration>
<forced_do_shipment_with_invoice>forced_shipment_with_invoice</forced_do_shipment_with_invoice>
<base_shipping_hidden_tax_amount>base_shipping_hidden_tax_amnt</base_shipping_hidden_tax_amount>
</order>
</old_fields_map>
<quote>
<totals>
<nominal>
Expand Down
11 changes: 0 additions & 11 deletions app/code/core/Mage/Weee/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,6 @@
</weee>
</totals>
</order_creditmemo>
<old_fields_map>
<order_item>
<base_weee_tax_applied_row_amount>base_weee_tax_applied_row_amnt</base_weee_tax_applied_row_amount>
</order_item>
<invoice_item>
<base_weee_tax_applied_row_amount>base_weee_tax_applied_row_amnt</base_weee_tax_applied_row_amount>
</invoice_item>
<creditmemo_item>
<base_weee_tax_applied_row_amount>base_weee_tax_applied_row_amnt</base_weee_tax_applied_row_amount>
</creditmemo_item>
</old_fields_map>
</sales>
</global>
<adminhtml>
Expand Down

0 comments on commit aa16d98

Please sign in to comment.