Skip to content

Commit e15d959

Browse files
committed
Make oldFields mapping hardcoded to speed up system
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
1 parent c6f200c commit e15d959

File tree

8 files changed

+19
-34
lines changed

8 files changed

+19
-34
lines changed

app/code/core/Mage/Catalog/Model/Product.php

-12
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,6 @@ protected function _construct()
118118
$this->_init('catalog/product');
119119
}
120120

121-
/**
122-
* Init mapping array of short fields to
123-
* its full names
124-
*
125-
* @return Varien_Object
126-
*/
127-
protected function _initOldFieldsMap()
128-
{
129-
$this->_oldFieldsMap = Mage::helper('catalog')->getOldFieldMap();
130-
return $this;
131-
}
132-
133121
/**
134122
* Retrieve Store Id
135123
*

app/code/core/Mage/CatalogInventory/Model/Stock/Item.php

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ protected function _construct()
152152
*/
153153
protected function _initOldFieldsMap()
154154
{
155+
// pre 1.6 fields names, old => new
155156
$this->_oldFieldsMap = array(
156157
'stock_status_changed_automatically' => 'stock_status_changed_auto',
157158
'use_config_enable_qty_increments' => 'use_config_enable_qty_inc'

app/code/core/Mage/Sales/Model/Order.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,12 @@ protected function _construct()
431431
*/
432432
protected function _initOldFieldsMap()
433433
{
434-
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order');
434+
// pre 1.6 fields names, old => new
435+
$this->_oldFieldsMap = [
436+
'payment_authorization_expiration' => 'payment_auth_expiration',
437+
'forced_do_shipment_with_invoice' => 'forced_shipment_with_invoice',
438+
'base_shipping_hidden_tax_amount' => 'base_shipping_hidden_tax_amnt',
439+
];
435440
return $this;
436441
}
437442

app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ public function setCreditmemo(Mage_Sales_Model_Order_Creditmemo $creditmemo)
132132
*/
133133
protected function _initOldFieldsMap()
134134
{
135-
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('creditmemo_item');
135+
// pre 1.6 fields names, old => new
136+
$this->_oldFieldsMap = [
137+
'base_weee_tax_applied_row_amount' => 'base_weee_tax_applied_row_amnt',
138+
];
136139
return $this;
137140
}
138141

app/code/core/Mage/Sales/Model/Order/Invoice/Item.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,10 @@ function _construct()
122122
*/
123123
protected function _initOldFieldsMap()
124124
{
125-
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('invoice_item');
125+
// pre 1.6 fields names, old => new
126+
$this->_oldFieldsMap = [
127+
'base_weee_tax_applied_row_amount' => 'base_weee_tax_applied_row_amnt',
128+
];
126129
return $this;
127130
}
128131
/**

app/code/core/Mage/Sales/Model/Order/Item.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,10 @@ protected function _construct()
236236
*/
237237
protected function _initOldFieldsMap()
238238
{
239-
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order_item');
239+
// pre 1.6 fields names, old => new
240+
$this->_oldFieldsMap = [
241+
'base_weee_tax_applied_row_amount' => 'base_weee_tax_applied_row_amnt',
242+
];
240243
return $this;
241244
}
242245

app/code/core/Mage/Sales/etc/config.xml

-7
Original file line numberDiff line numberDiff line change
@@ -1198,13 +1198,6 @@
11981198
</product>
11991199
</catalog>
12001200
<sales>
1201-
<old_fields_map>
1202-
<order>
1203-
<payment_authorization_expiration>payment_auth_expiration</payment_authorization_expiration>
1204-
<forced_do_shipment_with_invoice>forced_shipment_with_invoice</forced_do_shipment_with_invoice>
1205-
<base_shipping_hidden_tax_amount>base_shipping_hidden_tax_amnt</base_shipping_hidden_tax_amount>
1206-
</order>
1207-
</old_fields_map>
12081201
<quote>
12091202
<totals>
12101203
<nominal>

app/code/core/Mage/Weee/etc/config.xml

-11
Original file line numberDiff line numberDiff line change
@@ -225,17 +225,6 @@
225225
</weee>
226226
</totals>
227227
</order_creditmemo>
228-
<old_fields_map>
229-
<order_item>
230-
<base_weee_tax_applied_row_amount>base_weee_tax_applied_row_amnt</base_weee_tax_applied_row_amount>
231-
</order_item>
232-
<invoice_item>
233-
<base_weee_tax_applied_row_amount>base_weee_tax_applied_row_amnt</base_weee_tax_applied_row_amount>
234-
</invoice_item>
235-
<creditmemo_item>
236-
<base_weee_tax_applied_row_amount>base_weee_tax_applied_row_amnt</base_weee_tax_applied_row_amount>
237-
</creditmemo_item>
238-
</old_fields_map>
239228
</sales>
240229
</global>
241230
<adminhtml>

0 commit comments

Comments
 (0)