Skip to content

Commit 43c8c10

Browse files
ENGCOM-5530: Resolve Customer sent newsletter unsubscribe email when registering for a new account and newsletter confirmation is on (issue 23729) #23737
- Merge Pull Request #23737 from edenduong/magento2:2.3-bugfix/issue23729 - Merged commits: 1. 8604be9 2. fc1687b 3. f25dfd3
2 parents c6427d1 + f25dfd3 commit 43c8c10

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

app/code/Magento/Customer/Controller/Account/CreatePost.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Customer\Controller\Account;
79

810
use Magento\Customer\Api\CustomerRepositoryInterface as CustomerRepository;
@@ -349,15 +351,14 @@ public function execute()
349351
$confirmation = $this->getRequest()->getParam('password_confirmation');
350352
$redirectUrl = $this->session->getBeforeAuthUrl();
351353
$this->checkPasswordConfirmation($password, $confirmation);
354+
355+
$extensionAttributes = $customer->getExtensionAttributes();
356+
$extensionAttributes->setIsSubscribed($this->getRequest()->getParam('is_subscribed', false));
357+
$customer->setExtensionAttributes($extensionAttributes);
358+
352359
$customer = $this->accountManagement
353360
->createAccount($customer, $password, $redirectUrl);
354361

355-
if ($this->getRequest()->getParam('is_subscribed', false)) {
356-
$extensionAttributes = $customer->getExtensionAttributes();
357-
$extensionAttributes->setIsSubscribed(true);
358-
$customer->setExtensionAttributes($extensionAttributes);
359-
$this->customerRepository->save($customer);
360-
}
361362
$this->_eventManager->dispatch(
362363
'customer_register_success',
363364
['account_controller' => $this, 'customer' => $customer]

0 commit comments

Comments
 (0)