Skip to content

Commit aa16d98

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: OpenMage#920
1 parent ae2520c commit aa16d98

File tree

15 files changed

+19
-30
lines changed

15 files changed

+19
-30
lines changed

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

-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,6 @@ protected function _construct()
360360
*/
361361
protected function _initOldFieldsMap()
362362
{
363-
$this->_oldFieldsMap = Mage::helper('catalog')->getOldFieldMap();
364363
return $this;
365364
}
366365

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

+1
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ protected function _construct()
177177
*/
178178
protected function _initOldFieldsMap()
179179
{
180+
// pre 1.6 fields names, old => new
180181
$this->_oldFieldsMap = array(
181182
'stock_status_changed_automatically' => 'stock_status_changed_auto',
182183
'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
@@ -526,7 +526,12 @@ protected function _construct()
526526
*/
527527
protected function _initOldFieldsMap()
528528
{
529-
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order');
529+
// pre 1.6 fields names, old => new
530+
$this->_oldFieldsMap = [
531+
'payment_authorization_expiration' => 'payment_auth_expiration',
532+
'forced_do_shipment_with_invoice' => 'forced_shipment_with_invoice',
533+
'base_shipping_hidden_tax_amount' => 'base_shipping_hidden_tax_amnt',
534+
];
530535
return $this;
531536
}
532537

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

-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ protected function _construct()
112112
*/
113113
protected function _initOldFieldsMap()
114114
{
115-
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order_address');
116115
return $this;
117116
}
118117

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

-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ protected function _construct()
224224
*/
225225
protected function _initOldFieldsMap()
226226
{
227-
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order_creditmemo');
228227
return $this;
229228
}
230229

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ public function setCreditmemo(Mage_Sales_Model_Order_Creditmemo $creditmemo)
153153
*/
154154
protected function _initOldFieldsMap()
155155
{
156-
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('creditmemo_item');
156+
// pre 1.6 fields names, old => new
157+
$this->_oldFieldsMap = [
158+
'base_weee_tax_applied_row_amount' => 'base_weee_tax_applied_row_amnt',
159+
];
157160
return $this;
158161
}
159162

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

-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ protected function _construct()
223223
*/
224224
protected function _initOldFieldsMap()
225225
{
226-
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order_invoice');
227226
return $this;
228227
}
229228

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ public function _construct()
125125
*/
126126
protected function _initOldFieldsMap()
127127
{
128-
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('invoice_item');
128+
// pre 1.6 fields names, old => new
129+
$this->_oldFieldsMap = [
130+
'base_weee_tax_applied_row_amount' => 'base_weee_tax_applied_row_amnt',
131+
];
129132
return $this;
130133
}
131134
/**

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,10 @@ protected function _construct()
246246
*/
247247
protected function _initOldFieldsMap()
248248
{
249-
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order_item');
249+
// pre 1.6 fields names, old => new
250+
$this->_oldFieldsMap = [
251+
'base_weee_tax_applied_row_amount' => 'base_weee_tax_applied_row_amnt',
252+
];
250253
return $this;
251254
}
252255

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

-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ protected function _construct()
127127
*/
128128
protected function _initOldFieldsMap()
129129
{
130-
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order_shipment');
131130
return $this;
132131
}
133132

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

-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ protected function _construct()
262262
*/
263263
protected function _initOldFieldsMap()
264264
{
265-
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('quote');
266265
return $this;
267266
}
268267

app/code/core/Mage/Sales/Model/Quote/Address.php

-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ protected function _construct()
321321
*/
322322
protected function _initOldFieldsMap()
323323
{
324-
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('quote_address');
325324
return $this;
326325
}
327326

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

-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ protected function _construct()
247247
*/
248248
protected function _initOldFieldsMap()
249249
{
250-
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('quote_item');
251250
return $this;
252251
}
253252

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)