您好我正在使用magento中的默认新闻简报订阅包。如果用户已经注册了我,我需要显示错误我已经看到过像这样的选项
$emailExist = Mage::getModel('newsletter/subscriber')->load($email, 'subscriber_email');
if ($emailExist->getId()) {
Mage::throwException($this->__('This email address is already exist.'));
}
从这里Show error message in guest subscriber if user already subscribe with that Id
但这对我不起作用,我仍然感谢订阅消息。感谢
答案 0 :(得分:2)
检查这个............
$NewSellt= Mage::getModel('newsletter/subscriber')->subscribe($email);
if($NewSellt->getId()>0){
//if exits
}
如果客户是注册用户
$ownerId = Mage::getModel('customer/customer')
->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
->loadByEmail($email)
->getId();
if ($ownerId !== null && $ownerId != $customerSession->getId()) {
//'This email address is already assigned to another user.
}