Skip to content

Commit

Permalink
Merge forwardport of #13044 to 2.3-develop branch
Browse files Browse the repository at this point in the history
Applied pull request patch https://github.com/magento/magento2/pull/13044.patch (created by @torhoehn) based on commit(s):
  1. 9ab75ba
  2. 93453a8

Fixed GitHub Issues in 2.3-develop branch:
  - #12876: Multiple newsletter confirmation emails sent (reported by @nfourteen)
  • Loading branch information
magento-engcom-team authored Feb 5, 2018
2 parents 6114120 + 7c61506 commit 63b4839
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions app/code/Magento/Newsletter/Model/Subscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -604,14 +604,20 @@ protected function _updateCustomerSubscription($customerId, $subscribe)

$this->save();
$sendSubscription = $sendInformationEmail;
if ($sendSubscription === null xor $sendSubscription) {
if ($sendSubscription === null xor $sendSubscription && $this->isStatusChanged()) {
try {
if ($isConfirmNeed) {
$this->sendConfirmationRequestEmail();
} elseif ($this->isStatusChanged() && $status == self::STATUS_UNSUBSCRIBED) {
$this->sendUnsubscriptionEmail();
} elseif ($this->isStatusChanged() && $status == self::STATUS_SUBSCRIBED) {
$this->sendConfirmationSuccessEmail();
switch ($status) {
case self::STATUS_UNSUBSCRIBED:
$this->sendUnsubscriptionEmail();
break;
case self::STATUS_SUBSCRIBED:
$this->sendConfirmationSuccessEmail();
break;
case self::STATUS_NOT_ACTIVE:
if ($isConfirmNeed) {
$this->sendConfirmationRequestEmail();
}
break;
}
} catch (MailException $e) {
// If we are not able to send a new account email, this should be ignored
Expand Down

0 comments on commit 63b4839

Please sign in to comment.