0

I am using default Magento2.2.4. The subscription is working correctly. But when I am entering an email again, it is not showing any error. So if I enter test@test.com then I am getting subscribed in the list in admin. Which is correct. But if I enter the same email a second time, I am still getting success message, but ideally there should be a message that you are already subscribed.

Can someone help on how to fix this?

0

I fixed the issue by using the below in my controller constructor-

\Magento\Newsletter\Model\Subscriber $subscriber,

Earlier I was using the Factory, but not sure why it was not working correctly. So I can using this and a work around

$checkSubscriber = $this->_subscriber->loadByEmail($email); 
                    if ($checkSubscriber->isSubscribed()) {
                        $response = [
                            'status' => 'ERROR',
                            'msg' => __('Something went wrong with the subscription.'),
                        ];                        

                    }
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.