Skip to content

Commit 0d2bb65

Browse files
tmotylMarcin Nowak
authored andcommitted
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 0d2bb65

File tree

15 files changed

+19
-30
lines changed

15 files changed

+19
-30
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ protected function _construct()
126126
*/
127127
protected function _initOldFieldsMap()
128128
{
129-
$this->_oldFieldsMap = Mage::helper('catalog')->getOldFieldMap();
130129
return $this;
131130
}
132131

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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 6 additions & 1 deletion
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/Address.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ protected function _construct()
9393
*/
9494
protected function _initOldFieldsMap()
9595
{
96-
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order_address');
9796
return $this;
9897
}
9998

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ protected function _construct()
185185
*/
186186
protected function _initOldFieldsMap()
187187
{
188-
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order_creditmemo');
189188
return $this;
190189
}
191190

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

Lines changed: 4 additions & 1 deletion
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.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ protected function _construct()
204204
*/
205205
protected function _initOldFieldsMap()
206206
{
207-
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order_invoice');
208207
return $this;
209208
}
210209

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

Lines changed: 4 additions & 1 deletion
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

Lines changed: 4 additions & 1 deletion
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/Model/Order/Shipment.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ protected function _construct()
108108
*/
109109
protected function _initOldFieldsMap()
110110
{
111-
$this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order_shipment');
112111
return $this;
113112
}
114113

0 commit comments

Comments
 (0)