File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed
app/code/Magento/Customer/Observer Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change 8
8
9
9
use Magento \Framework \Event \ObserverInterface ;
10
10
use Magento \Framework \Event \Observer ;
11
+ use Magento \Framework \Exception \NoSuchEntityException ;
11
12
use Magento \Quote \Api \CartRepositoryInterface ;
12
13
13
14
/**
@@ -43,13 +44,17 @@ public function execute(Observer $observer)
43
44
44
45
/** @var \Magento\Customer\Model\Data\Customer $customerOrig */
45
46
$ 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
+ }
53
58
}
54
59
}
55
60
}
You can’t perform that action at this time.
0 commit comments