Skip to content

Commit 765999d

Browse files
MAGETWO-39857: Event 'customer_save_after_data_object' dispatches a few times
1 parent 50f160d commit 765999d

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

app/code/Magento/Quote/Model/Observer/Backend/CustomerQuote.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ public function dispatch(Observer $observer)
5555
{
5656
/** @var \Magento\Customer\Api\Data\CustomerInterface $customer */
5757
$customer = $observer->getEvent()->getCustomerDataObject();
58-
/** @var \Magento\Customer\Api\Data\CustomerInterface $origCustomer */
59-
$origCustomer = $observer->getEvent()->getOrigCustomerDataObject();
60-
if ($customer->getGroupId() !== $origCustomer->getGroupId()) {
58+
try {
59+
$quote = $this->quoteRepository->getForCustomer($customer->getId());
60+
if ($customer->getGroupId() !== $quote->getCustomerGroupId()) {
6161
/**
6262
* It is needed to process customer's quotes for all websites
6363
* if customer accounts are shared between all of them
@@ -68,15 +68,13 @@ public function dispatch(Observer $observer)
6868
: $this->storeManager->getWebsites();
6969

7070
foreach ($websites as $website) {
71-
try {
72-
$quote = $this->quoteRepository->getForCustomer($customer->getId());
7371
$quote->setWebsite($website);
7472
$quote->setCustomerGroupId($customer->getGroupId());
7573
$quote->collectTotals();
7674
$this->quoteRepository->save($quote);
77-
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
7875
}
7976
}
77+
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
8078
}
8179
}
8280
}

0 commit comments

Comments
 (0)