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

Commit b6c78a4

Browse files
committed
Check if necessary send email to subscribers
1 parent d30f077 commit b6c78a4

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

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

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

398399
if (!$this->getId()) {
399400
$this->setSubscriberConfirmCode($this->randomSequence());
401+
$sendInformationEmail = true;
400402
}
401403

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

0 commit comments

Comments
 (0)