Skip to content

Commit 461aa96

Browse files
author
Hayder Sharhan
committed
Merge commit 'refs/pull/3973/head' of https://github.com/magento/magento2 into MAGETWO-54152
2 parents 2d0d716 + 3f490b4 commit 461aa96

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@ public function execute()
121121
$this->validateGuestSubscription();
122122
$this->validateEmailAvailable($email);
123123

124+
$subscriber = $this->_subscriberFactory->create()->loadByEmail($email);
125+
if ($subscriber->getId()
126+
&& $subscriber->getSubscriberStatus() == \Magento\Newsletter\Model\Subscriber::STATUS_SUBSCRIBED
127+
) {
128+
throw new \Magento\Framework\Exception\LocalizedException(
129+
__('This email address is already subscribed.')
130+
);
131+
}
132+
124133
$status = $this->_subscriberFactory->create()->subscribe($email);
125134
if ($status == \Magento\Newsletter\Model\Subscriber::STATUS_NOT_ACTIVE) {
126135
$this->messageManager->addSuccess(__('The confirmation request has been sent.'));

0 commit comments

Comments
 (0)