Skip to content

Commit

Permalink
fix bug on newsletter subscription action when user use an existing e…
Browse files Browse the repository at this point in the history
…mail already subscribed
  • Loading branch information
manfrinm committed Apr 1, 2016
1 parent 2abc5a3 commit 3f490b4
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ public function execute()
$this->validateGuestSubscription();
$this->validateEmailAvailable($email);

$subscriber = $this->_subscriberFactory->create()->loadByEmail($email);
if ($subscriber->getId()
&& $subscriber->getSubscriberStatus() == \Magento\Newsletter\Model\Subscriber::STATUS_SUBSCRIBED
) {
throw new \Magento\Framework\Exception\LocalizedException(
__('This email address is already subscribed.')
);
}

$status = $this->_subscriberFactory->create()->subscribe($email);
if ($status == \Magento\Newsletter\Model\Subscriber::STATUS_NOT_ACTIVE) {
$this->messageManager->addSuccess(__('The confirmation request has been sent.'));
Expand Down

0 comments on commit 3f490b4

Please sign in to comment.