Skip to content

Commit 1643c30

Browse files
committed
ACP2E-279: Customer details are lost after editing an order.
1 parent 8e9b34b commit 1643c30

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

app/code/Magento/Sales/Model/AdminOrder/Create.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,20 +1829,12 @@ protected function _validateCustomerData(\Magento\Customer\Api\Data\CustomerInte
18291829
*/
18301830
public function _prepareCustomer()
18311831
{
1832-
/** @var $store \Magento\Store\Model\Store */
1833-
$store = $this->getSession()->getStore();
1834-
$customer = $this->getQuote()->getCustomer();
18351832
if ($this->getQuote()->getCustomerIsGuest()) {
1836-
$customerBillingAddressDataObject = $this->getBillingAddress()->exportCustomerAddress();
1837-
$customer->setFirstname($customerBillingAddressDataObject->getFirstname())
1838-
->setLastname($customerBillingAddressDataObject->getLastname())
1839-
->setMiddlename($customerBillingAddressDataObject->getMiddlename())
1840-
->setStoreId($store->getId())
1841-
->setWebsiteId($store->getWebsiteId());
1842-
$customer = $this->_validateCustomerData($customer);
1843-
$this->getQuote()->setCustomer($customer);
18441833
return $this;
18451834
}
1835+
/** @var $store \Magento\Store\Model\Store */
1836+
$store = $this->getSession()->getStore();
1837+
$customer = $this->getQuote()->getCustomer();
18461838

18471839
if ($customer->getId() && !$this->_customerIsInStore($store)) {
18481840
/** Create a new customer record if it is not available in the specified store */
@@ -2012,6 +2004,15 @@ public function createOrder()
20122004
$oldOrder->setRelationChildId($order->getId());
20132005
$oldOrder->setRelationChildRealId($order->getIncrementId());
20142006
$oldOrder->save();
2007+
if ($order->getCustomerIsGuest()) {
2008+
$quote->setCustomerFirstname($oldOrder->getCustomerFirstname());
2009+
$quote->setCustomerMiddlename($oldOrder->getCustomerMiddlename());
2010+
$quote->setCustomerLastname($oldOrder->getCustomerLastname());
2011+
$quote->save();
2012+
$order->setCustomerFirstname($oldOrder->getCustomerFirstname());
2013+
$order->setCustomerMiddlename($oldOrder->getCustomerMiddlename());
2014+
$order->setCustomerLastname($oldOrder->getCustomerLastname());
2015+
}
20152016
$this->orderManagement->cancel($oldOrder->getEntityId());
20162017
$order->save();
20172018
}

0 commit comments

Comments
 (0)