嗨,我在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

但这对我不起作用,我仍然对订阅消息表示同样的感谢。谢谢

最佳答案

检查这个............

$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.
                }

关于Magento通讯订阅-如果已订阅,则显示错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23362583/

10-10 14:16