From 45a354abe028f5c0eefa3375ad52ea6ec7170a16 Mon Sep 17 00:00:00 2001 From: sv3n Date: Fri, 16 Dec 2022 10:28:12 +0100 Subject: [PATCH 1/2] Some code alignments between v19 and v20 (#2810) --- app/code/core/Mage/Sales/Model/Order.php | 26 ++++++++----------- .../core/Mage/Sales/Model/Order/Address.php | 1 + .../Mage/Sales/Model/Order/Creditmemo.php | 1 + .../Sales/Model/Order/Creditmemo/Item.php | 4 +-- .../core/Mage/Sales/Model/Order/Invoice.php | 1 + .../Mage/Sales/Model/Order/Invoice/Item.php | 14 +++------- app/code/core/Mage/Sales/Model/Order/Item.php | 6 ++--- .../core/Mage/Sales/Model/Order/Shipment.php | 1 + app/code/core/Mage/Sales/Model/Quote.php | 1 + .../core/Mage/Sales/Model/Quote/Address.php | 1 + app/code/core/Mage/Sales/Model/Quote/Item.php | 1 + 11 files changed, 25 insertions(+), 32 deletions(-) diff --git a/app/code/core/Mage/Sales/Model/Order.php b/app/code/core/Mage/Sales/Model/Order.php index 9922091e6fe..0f8448552c7 100644 --- a/app/code/core/Mage/Sales/Model/Order.php +++ b/app/code/core/Mage/Sales/Model/Order.php @@ -441,42 +441,42 @@ class Mage_Sales_Model_Order extends Mage_Sales_Model_Abstract protected $_eventObject = 'order'; /** - * @var Mage_Sales_Model_Resource_Order_Address_Collection|Mage_Sales_Model_Order_Address[]|null + * @var Mage_Sales_Model_Resource_Order_Address_Collection|Mage_Sales_Model_Order_Address[] */ protected $_addresses = null; /** - * @var Mage_Sales_Model_Resource_Order_Item_Collection|Mage_Sales_Model_Order_Item[]|null + * @var Mage_Sales_Model_Resource_Order_Item_Collection|Mage_Sales_Model_Order_Item[] */ protected $_items = null; /** - * @var Mage_Sales_Model_Resource_Order_Payment_Collection|Mage_Sales_Model_Order_Payment[]|null + * @var Mage_Sales_Model_Resource_Order_Payment_Collection|Mage_Sales_Model_Order_Payment[] */ protected $_payments = null; /** - * @var Mage_Sales_Model_Resource_Order_Status_History_Collection|Mage_Sales_Model_Order_Status_History[]|null + * @var Mage_Sales_Model_Resource_Order_Status_History_Collection|Mage_Sales_Model_Order_Status_History[] */ protected $_statusHistory = null; /** - * @var Mage_Sales_Model_Resource_Order_Invoice_Collection|null + * @var Mage_Sales_Model_Resource_Order_Invoice_Collection */ protected $_invoices; /** - * @var Mage_Sales_Model_Resource_Order_Shipment_Track_Collection|null + * @var Mage_Sales_Model_Resource_Order_Shipment_Track_Collection */ protected $_tracks; /** - * @var Mage_Sales_Model_Resource_Order_Shipment_Collection|false|null + * @var Mage_Sales_Model_Resource_Order_Shipment_Collection|false */ protected $_shipments; /** - * @var Mage_Sales_Model_Resource_Order_Creditmemo_Collection|Mage_Sales_Model_Order_Creditmemo[]|false|null + * @var Mage_Sales_Model_Resource_Order_Creditmemo_Collection|Mage_Sales_Model_Order_Creditmemo[]|false */ protected $_creditmemos; @@ -519,11 +519,7 @@ protected function _construct() protected function _initOldFieldsMap() { // 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', - ]; + $this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order'); return $this; } @@ -1745,7 +1741,7 @@ public function getAllVisibleItems() $items = []; foreach ($this->getItemsCollection() as $item) { if (!$item->isDeleted() && !$item->getParentItemId()) { - $items[] = $item; + $items[] = $item; } } return $items; @@ -1753,7 +1749,7 @@ public function getAllVisibleItems() /** * @param int $itemId - * @return Mage_Sales_Model_Order_Item|null + * @return Varien_Object|null */ public function getItemById($itemId) { diff --git a/app/code/core/Mage/Sales/Model/Order/Address.php b/app/code/core/Mage/Sales/Model/Order/Address.php index ad977a74284..b1eac9ec6d3 100644 --- a/app/code/core/Mage/Sales/Model/Order/Address.php +++ b/app/code/core/Mage/Sales/Model/Order/Address.php @@ -104,6 +104,7 @@ protected function _construct() * Init mapping array of short fields to its full names * * @return $this + * @deprecated */ protected function _initOldFieldsMap() { diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php index cec38de24ef..0dffab8e7ed 100644 --- a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php +++ b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php @@ -217,6 +217,7 @@ protected function _construct() * Init mapping array of short fields to its full names * * @return $this + * @deprecated */ protected function _initOldFieldsMap() { diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php b/app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php index 712d8259d79..04e5e2da88e 100644 --- a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php +++ b/app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php @@ -144,9 +144,7 @@ public function setCreditmemo(Mage_Sales_Model_Order_Creditmemo $creditmemo) protected function _initOldFieldsMap() { // pre 1.6 fields names, old => new - $this->_oldFieldsMap = [ - 'base_weee_tax_applied_row_amount' => 'base_weee_tax_applied_row_amnt', - ]; + $this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('creditmemo_item'); return $this; } diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice.php b/app/code/core/Mage/Sales/Model/Order/Invoice.php index dbdc6dff7df..2c498dcac2b 100644 --- a/app/code/core/Mage/Sales/Model/Order/Invoice.php +++ b/app/code/core/Mage/Sales/Model/Order/Invoice.php @@ -212,6 +212,7 @@ protected function _construct() * Init mapping array of short fields to its full names * * @return $this + * @deprecated */ protected function _initOldFieldsMap() { diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice/Item.php b/app/code/core/Mage/Sales/Model/Order/Invoice/Item.php index 22fb94109d1..0a45cd836bd 100644 --- a/app/code/core/Mage/Sales/Model/Order/Invoice/Item.php +++ b/app/code/core/Mage/Sales/Model/Order/Invoice/Item.php @@ -96,14 +96,10 @@ class Mage_Sales_Model_Order_Invoice_Item extends Mage_Core_Model_Abstract protected $_eventPrefix = 'sales_invoice_item'; protected $_eventObject = 'invoice_item'; - /** - * @var Mage_Sales_Model_Order_Invoice - */ + /** @var Mage_Sales_Model_Order_Invoice */ protected $_invoice = null; - /** - * @var Mage_Sales_Model_Order_Item|null - */ + /** @var Mage_Sales_Model_Order_Item */ protected $_orderItem = null; public function _construct() @@ -115,14 +111,12 @@ public function _construct() * Init mapping array of short fields to * its full names * - * @return $this + * @return Varien_Object */ protected function _initOldFieldsMap() { // pre 1.6 fields names, old => new - $this->_oldFieldsMap = [ - 'base_weee_tax_applied_row_amount' => 'base_weee_tax_applied_row_amnt', - ]; + $this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('invoice_item'); return $this; } /** diff --git a/app/code/core/Mage/Sales/Model/Order/Item.php b/app/code/core/Mage/Sales/Model/Order/Item.php index 4cc17cb61c9..25aa169ecf0 100644 --- a/app/code/core/Mage/Sales/Model/Order/Item.php +++ b/app/code/core/Mage/Sales/Model/Order/Item.php @@ -221,7 +221,6 @@ class Mage_Sales_Model_Order_Item extends Mage_Core_Model_Abstract * @var Mage_Sales_Model_Order|null */ protected $_order = null; - protected $_parentItem = null; protected $_children = []; @@ -238,13 +237,12 @@ protected function _construct() * its full names * * @return Varien_Object + * @deprecated */ protected function _initOldFieldsMap() { // pre 1.6 fields names, old => new - $this->_oldFieldsMap = [ - 'base_weee_tax_applied_row_amount' => 'base_weee_tax_applied_row_amnt', - ]; + $this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order_item'); return $this; } diff --git a/app/code/core/Mage/Sales/Model/Order/Shipment.php b/app/code/core/Mage/Sales/Model/Order/Shipment.php index 39bc21fb9e1..f6793e4ef52 100644 --- a/app/code/core/Mage/Sales/Model/Order/Shipment.php +++ b/app/code/core/Mage/Sales/Model/Order/Shipment.php @@ -119,6 +119,7 @@ protected function _construct() * Init mapping array of short fields to its full names * * @return $this + * @deprecated */ protected function _initOldFieldsMap() { diff --git a/app/code/core/Mage/Sales/Model/Quote.php b/app/code/core/Mage/Sales/Model/Quote.php index 405246bd099..3fe913c8271 100644 --- a/app/code/core/Mage/Sales/Model/Quote.php +++ b/app/code/core/Mage/Sales/Model/Quote.php @@ -254,6 +254,7 @@ protected function _construct() * its full names * * @return Varien_Object + * @deprecated */ protected function _initOldFieldsMap() { diff --git a/app/code/core/Mage/Sales/Model/Quote/Address.php b/app/code/core/Mage/Sales/Model/Quote/Address.php index e522cd5959a..86b6e9fd762 100644 --- a/app/code/core/Mage/Sales/Model/Quote/Address.php +++ b/app/code/core/Mage/Sales/Model/Quote/Address.php @@ -314,6 +314,7 @@ protected function _construct() * Init mapping array of short fields to its full names * * @return $this + * @deprecated */ protected function _initOldFieldsMap() { diff --git a/app/code/core/Mage/Sales/Model/Quote/Item.php b/app/code/core/Mage/Sales/Model/Quote/Item.php index 07ecc6c0884..8f0500a659d 100644 --- a/app/code/core/Mage/Sales/Model/Quote/Item.php +++ b/app/code/core/Mage/Sales/Model/Quote/Item.php @@ -236,6 +236,7 @@ protected function _construct() * its full names * * @return $this + * @deprecated */ protected function _initOldFieldsMap() { From 91c3b9c6e88585cc7d649c3521e8f570819d5b89 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Tue, 3 Jan 2023 22:59:00 +0100 Subject: [PATCH 2/2] Comments by @tmotyl --- app/code/core/Mage/Sales/Model/Order.php | 10 +++++++--- .../core/Mage/Sales/Model/Order/Creditmemo/Item.php | 4 +++- app/code/core/Mage/Sales/Model/Order/Invoice/Item.php | 6 ++++-- app/code/core/Mage/Sales/Model/Order/Item.php | 4 +++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/code/core/Mage/Sales/Model/Order.php b/app/code/core/Mage/Sales/Model/Order.php index 0f8448552c7..2c90b99f6ae 100644 --- a/app/code/core/Mage/Sales/Model/Order.php +++ b/app/code/core/Mage/Sales/Model/Order.php @@ -441,7 +441,7 @@ class Mage_Sales_Model_Order extends Mage_Sales_Model_Abstract protected $_eventObject = 'order'; /** - * @var Mage_Sales_Model_Resource_Order_Address_Collection|Mage_Sales_Model_Order_Address[] + * @var Mage_Sales_Model_Resource_Order_Address_Collection|Mage_Sales_Model_Order_Address[]|null */ protected $_addresses = null; @@ -519,7 +519,11 @@ protected function _construct() protected function _initOldFieldsMap() { // pre 1.6 fields names, old => new - $this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order'); + $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; } @@ -1749,7 +1753,7 @@ public function getAllVisibleItems() /** * @param int $itemId - * @return Varien_Object|null + * @return Mage_Sales_Model_Order_Item|null */ public function getItemById($itemId) { diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php b/app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php index 04e5e2da88e..712d8259d79 100644 --- a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php +++ b/app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php @@ -144,7 +144,9 @@ public function setCreditmemo(Mage_Sales_Model_Order_Creditmemo $creditmemo) protected function _initOldFieldsMap() { // pre 1.6 fields names, old => new - $this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('creditmemo_item'); + $this->_oldFieldsMap = [ + 'base_weee_tax_applied_row_amount' => 'base_weee_tax_applied_row_amnt', + ]; return $this; } diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice/Item.php b/app/code/core/Mage/Sales/Model/Order/Invoice/Item.php index 0a45cd836bd..7b751830801 100644 --- a/app/code/core/Mage/Sales/Model/Order/Invoice/Item.php +++ b/app/code/core/Mage/Sales/Model/Order/Invoice/Item.php @@ -111,12 +111,14 @@ public function _construct() * Init mapping array of short fields to * its full names * - * @return Varien_Object + * @return $this */ protected function _initOldFieldsMap() { // pre 1.6 fields names, old => new - $this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('invoice_item'); + $this->_oldFieldsMap = [ + 'base_weee_tax_applied_row_amount' => 'base_weee_tax_applied_row_amnt', + ]; return $this; } /** diff --git a/app/code/core/Mage/Sales/Model/Order/Item.php b/app/code/core/Mage/Sales/Model/Order/Item.php index 25aa169ecf0..82c116245c5 100644 --- a/app/code/core/Mage/Sales/Model/Order/Item.php +++ b/app/code/core/Mage/Sales/Model/Order/Item.php @@ -242,7 +242,9 @@ protected function _construct() protected function _initOldFieldsMap() { // pre 1.6 fields names, old => new - $this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order_item'); + $this->_oldFieldsMap = [ + 'base_weee_tax_applied_row_amount' => 'base_weee_tax_applied_row_amnt', + ]; return $this; }