Skip to content

Commit 5076e11

Browse files
committed
Forward port of 15097 to 2.3-develop branch.
1 parent 853e180 commit 5076e11

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

app/code/Magento/Sales/Setup/Patch/Data/FillQuoteAddressIdInSalesOrderAddress.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,27 +93,27 @@ public function apply()
9393
public function fillQuoteAddressIdInSalesOrderAddress()
9494
{
9595
$addressCollection = $this->addressCollectionFactory->create();
96+
$addressCollection->addFieldToFilter('quote_address_id', ['null' => true]);
97+
9698
/** @var \Magento\Sales\Model\Order\Address $orderAddress */
9799
foreach ($addressCollection as $orderAddress) {
98-
if (!$orderAddress->getData('quote_address_id')) {
99-
$orderId = $orderAddress->getParentId();
100-
$addressType = $orderAddress->getAddressType();
101-
102-
/** @var \Magento\Sales\Model\Order $order */
103-
$order = $this->orderFactory->create()->load($orderId);
104-
$quoteId = $order->getQuoteId();
105-
$quote = $this->quoteFactory->create()->load($quoteId);
106-
107-
if ($addressType == \Magento\Sales\Model\Order\Address::TYPE_SHIPPING) {
108-
$quoteAddressId = $quote->getShippingAddress()->getId();
109-
$orderAddress->setData('quote_address_id', $quoteAddressId);
110-
} elseif ($addressType == \Magento\Sales\Model\Order\Address::TYPE_BILLING) {
111-
$quoteAddressId = $quote->getBillingAddress()->getId();
112-
$orderAddress->setData('quote_address_id', $quoteAddressId);
113-
}
114-
115-
$orderAddress->save();
100+
$orderId = $orderAddress->getParentId();
101+
$addressType = $orderAddress->getAddressType();
102+
103+
/** @var \Magento\Sales\Model\Order $order */
104+
$order = $this->orderFactory->create()->load($orderId);
105+
$quoteId = $order->getQuoteId();
106+
$quote = $this->quoteFactory->create()->load($quoteId);
107+
108+
if ($addressType == \Magento\Sales\Model\Order\Address::TYPE_SHIPPING) {
109+
$quoteAddressId = $quote->getShippingAddress()->getId();
110+
$orderAddress->setData('quote_address_id', $quoteAddressId);
111+
} elseif ($addressType == \Magento\Sales\Model\Order\Address::TYPE_BILLING) {
112+
$quoteAddressId = $quote->getBillingAddress()->getId();
113+
$orderAddress->setData('quote_address_id', $quoteAddressId);
116114
}
115+
116+
$orderAddress->save();
117117
}
118118
}
119119

0 commit comments

Comments
 (0)