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: OpenMage#920
  • Loading branch information
tmotyl committed Jun 26, 2020
1 parent 2b49516 commit d78eacc
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 34 deletions.
12 changes: 0 additions & 12 deletions app/code/core/Mage/Catalog/Model/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,18 +352,6 @@ protected function _construct()
$this->_init('catalog/product');
}

/**
* Init mapping array of short fields to
* its full names
*
* @return Varien_Object
*/
protected function _initOldFieldsMap()
{
$this->_oldFieldsMap = Mage::helper('catalog')->getOldFieldMap();
return $this;
}

/**
* Retrieve Store Id
*
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
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
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
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 d78eacc

Please sign in to comment.