diff --git a/app/code/Magento/Newsletter/Controller/Manage/Save.php b/app/code/Magento/Newsletter/Controller/Manage/Save.php index 419cbac10ffd1..738cff6bf87e9 100644 --- a/app/code/Magento/Newsletter/Controller/Manage/Save.php +++ b/app/code/Magento/Newsletter/Controller/Manage/Save.php @@ -75,13 +75,19 @@ public function execute() try { $customer = $this->customerRepository->getById($customerId); $storeId = $this->storeManager->getStore()->getId(); - $customer->setStoreId($storeId); + $isNeedToSaveCustomer = false; + if($customer->getStoreId() !== $storeId) { + $customer->setStoreId($storeId); + $isNeedToSaveCustomer = true; + } $isSubscribedState = $customer->getExtensionAttributes() ->getIsSubscribed(); $isSubscribedParam = (boolean)$this->getRequest() ->getParam('is_subscribed', false); if ($isSubscribedParam !== $isSubscribedState) { - $this->customerRepository->save($customer); + if($isNeedToSaveCustomer) { + $this->customerRepository->save($customer); + } if ($isSubscribedParam) { $subscribeModel = $this->subscriberFactory->create() ->subscribeCustomerById($customerId); diff --git a/app/code/Magento/Newsletter/Model/Plugin/CustomerPlugin.php b/app/code/Magento/Newsletter/Model/Plugin/CustomerPlugin.php index 58b51009c205a..c81a8193c67bd 100644 --- a/app/code/Magento/Newsletter/Model/Plugin/CustomerPlugin.php +++ b/app/code/Magento/Newsletter/Model/Plugin/CustomerPlugin.php @@ -71,7 +71,6 @@ public function afterSave(CustomerRepository $subject, CustomerInterface $result $resultId = $result->getId(); /** @var \Magento\Newsletter\Model\Subscriber $subscriber */ $subscriber = $this->subscriberFactory->create(); - $subscriber->updateSubscription($resultId); // update the result only if the original customer instance had different value. $initialExtensionAttributes = $result->getExtensionAttributes(); if ($initialExtensionAttributes === null) {