@@ -177,27 +177,27 @@ private function convertSerializedDataToJson($setupVersion, SalesSetup $salesSet
177
177
public function fillQuoteAddressIdInSalesOrderAddress ()
178
178
{
179
179
$ addressCollection = $ this ->addressCollectionFactory ->create ();
180
+ $ addressCollection ->addFieldToFilter ('quote_address_id ' , ['null ' => true ]);
181
+
180
182
/** @var \Magento\Sales\Model\Order\Address $orderAddress */
181
183
foreach ($ addressCollection as $ orderAddress ) {
182
- if (!$ orderAddress ->getData ('quote_address_id ' )) {
183
- $ orderId = $ orderAddress ->getParentId ();
184
- $ addressType = $ orderAddress ->getAddressType ();
185
-
186
- /** @var \Magento\Sales\Model\Order $order */
187
- $ order = $ this ->orderFactory ->create ()->load ($ orderId );
188
- $ quoteId = $ order ->getQuoteId ();
189
- $ quote = $ this ->quoteFactory ->create ()->load ($ quoteId );
190
-
191
- if ($ addressType == \Magento \Sales \Model \Order \Address::TYPE_SHIPPING ) {
192
- $ quoteAddressId = $ quote ->getShippingAddress ()->getId ();
193
- $ orderAddress ->setData ('quote_address_id ' , $ quoteAddressId );
194
- } elseif ($ addressType == \Magento \Sales \Model \Order \Address::TYPE_BILLING ) {
195
- $ quoteAddressId = $ quote ->getBillingAddress ()->getId ();
196
- $ orderAddress ->setData ('quote_address_id ' , $ quoteAddressId );
197
- }
198
-
199
- $ orderAddress ->save ();
184
+ $ orderId = $ orderAddress ->getParentId ();
185
+ $ addressType = $ orderAddress ->getAddressType ();
186
+
187
+ /** @var \Magento\Sales\Model\Order $order */
188
+ $ order = $ this ->orderFactory ->create ()->load ($ orderId );
189
+ $ quoteId = $ order ->getQuoteId ();
190
+ $ quote = $ this ->quoteFactory ->create ()->load ($ quoteId );
191
+
192
+ if ($ addressType == \Magento \Sales \Model \Order \Address::TYPE_SHIPPING ) {
193
+ $ quoteAddressId = $ quote ->getShippingAddress ()->getId ();
194
+ $ orderAddress ->setData ('quote_address_id ' , $ quoteAddressId );
195
+ } elseif ($ addressType == \Magento \Sales \Model \Order \Address::TYPE_BILLING ) {
196
+ $ quoteAddressId = $ quote ->getBillingAddress ()->getId ();
197
+ $ orderAddress ->setData ('quote_address_id ' , $ quoteAddressId );
200
198
}
199
+
200
+ $ orderAddress ->save ();
201
201
}
202
202
}
203
203
}
0 commit comments