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 authored and MarcinNowakMacopedia committed Apr 28, 2022
1 parent c6f200c commit 0d2bb65
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 @@ -126,7 +126,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 @@ -152,6 +152,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 @@ -431,7 +431,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 @@ -93,7 +93,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 @@ -185,7 +185,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 @@ -132,7 +132,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 @@ -204,7 +204,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 @@ -122,7 +122,10 @@ 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 @@ -236,7 +236,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 @@ -108,7 +108,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 @@ -208,7 +208,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 @@ -231,7 +231,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 @@ -211,7 +211,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 0d2bb65

Please sign in to comment.