Skip to content

Commit b0ba2ac

Browse files
committed
Check for existing origCustomerData. Catch NoSuchEnityException for cartRepository
1 parent 766db37 commit b0ba2ac

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

app/code/Magento/Customer/Observer/UpgradeQuoteCustomerEmailObserver.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use Magento\Framework\Event\ObserverInterface;
1010
use Magento\Framework\Event\Observer;
11+
use Magento\Framework\Exception\NoSuchEntityException;
1112
use Magento\Quote\Api\CartRepositoryInterface;
1213

1314
/**
@@ -43,13 +44,17 @@ public function execute(Observer $observer)
4344

4445
/** @var \Magento\Customer\Model\Data\Customer $customerOrig */
4546
$customerOrig = $observer->getEvent()->getOrigCustomerDataObject();
46-
$emailOrig = $customerOrig->getEmail();
47-
48-
if ($email != $emailOrig) {
49-
$quote = $this->quoteRepository->getForCustomer($customer->getId());
50-
$quote->setCustomerEmail($email);
51-
$this->quoteRepository->save($quote);
52-
47+
if ($customerOrig) {
48+
$emailOrig = $customerOrig->getEmail();
49+
50+
if ($email != $emailOrig) {
51+
try {
52+
$quote = $this->quoteRepository->getForCustomer($customer->getId());
53+
$quote->setCustomerEmail($email);
54+
$this->quoteRepository->save($quote);
55+
} catch (NoSuchEntityException $e) {
56+
}
57+
}
5358
}
5459
}
5560
}

0 commit comments

Comments
 (0)