【问题标题】:Magento Newletter subscription - show error if already subscribedMagento Newsletter 订阅 - 如果已订阅则显示错误
【发布时间】:2014-06-15 06:26:21
【问题描述】:

您好,我在 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

但这对我不起作用,我仍然感谢订阅消息。谢谢

【问题讨论】:

    标签: magento subscription newsletter


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多