Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 393bace

Browse files
committed
Changed logic to get customer subscriber status
1 parent f5daa7f commit 393bace

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

app/code/Magento/Newsletter/Model/Subscriber.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -393,12 +393,14 @@ public function randomSequence($length = 32)
393393
*/
394394
public function subscribe($email)
395395
{
396-
$sendInformationEmail = false;
397396
$this->loadByEmail($email);
398397

398+
if ($this->getId() && $this->getStatus() == self::STATUS_SUBSCRIBED) {
399+
return $this->getStatus();
400+
}
401+
399402
if (!$this->getId()) {
400403
$this->setSubscriberConfirmCode($this->randomSequence());
401-
$sendInformationEmail = true;
402404
}
403405

404406
$isConfirmNeed = $this->_scopeConfig->getValue(
@@ -446,14 +448,12 @@ public function subscribe($email)
446448
try {
447449
/* Save model before sending out email */
448450
$this->save();
449-
if ($sendInformationEmail) {
450-
if ($isConfirmNeed === true
451-
&& $isOwnSubscribes === false
452-
) {
453-
$this->sendConfirmationRequestEmail();
454-
} else {
455-
$this->sendConfirmationSuccessEmail();
456-
}
451+
if ($isConfirmNeed === true
452+
&& $isOwnSubscribes === false
453+
) {
454+
$this->sendConfirmationRequestEmail();
455+
} else {
456+
$this->sendConfirmationSuccessEmail();
457457
}
458458
return $this->getStatus();
459459
} catch (\Exception $e) {

0 commit comments

Comments
 (0)