From 9ab75baec089c4a327a0c3b082f0aaedfbfb15ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torben=20Ho=CC=88hn?= Date: Fri, 5 Jan 2018 16:36:04 +0100 Subject: [PATCH 1/2] updated newsletter subscriber model --- .../Magento/Newsletter/Model/Subscriber.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/Newsletter/Model/Subscriber.php b/app/code/Magento/Newsletter/Model/Subscriber.php index b8d7ccf83af7c..961ed539815e9 100644 --- a/app/code/Magento/Newsletter/Model/Subscriber.php +++ b/app/code/Magento/Newsletter/Model/Subscriber.php @@ -604,14 +604,19 @@ 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 From 93453a811e7cc5fb128fe7abd96233d47e010d4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torben=20H=C3=B6hn?= Date: Wed, 10 Jan 2018 09:46:19 +0100 Subject: [PATCH 2/2] removed inline control structure --- app/code/Magento/Newsletter/Model/Subscriber.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Newsletter/Model/Subscriber.php b/app/code/Magento/Newsletter/Model/Subscriber.php index 961ed539815e9..8f29798472f19 100644 --- a/app/code/Magento/Newsletter/Model/Subscriber.php +++ b/app/code/Magento/Newsletter/Model/Subscriber.php @@ -614,8 +614,9 @@ protected function _updateCustomerSubscription($customerId, $subscribe) $this->sendConfirmationSuccessEmail(); break; case self::STATUS_NOT_ACTIVE: - if ($isConfirmNeed) + if ($isConfirmNeed) { $this->sendConfirmationRequestEmail(); + } break; } } catch (MailException $e) {