no such entity. php,magento2 - Magento 2 - 新的题词通讯错误(没有这样的实体,customerId = 0) - SO中文参考 - www.soinside....

功能是:

供应商/的magento /模块的通讯/型号/ Subscriber.php

public function subscribe($email)

{

$this->loadByEmail($email);

if (!$this->getId()) {

$this->setSubscriberConfirmCode($this->randomSequence());

}

$isConfirmNeed = $this->_scopeConfig->getValue(

self::XML_PATH_CONFIRMATION_FLAG,

\Magento\Store\Model\ScopeInterface::SCOPE_STORE

) == 1 ? true : false;

$isOwnSubscribes = false;

$isSubscribeOwnEmail = $this->_customerSession->isLoggedIn()

&& $this->_customerSession->getCustomerDataObject()->getEmail() == $email;

if (!$this->getId() || $this->getStatus() == self::STATUS_UNSUBSCRIBED

|| $this->getStatus() == self::STATUS_NOT_ACTIVE

) {

if ($isConfirmNeed === true) {

// if user subscribes own login email - confirmation is not needed

$isOwnSubscribes = $isSubscribeOwnEmail;

if ($isOwnSubscribes == true) {

$this->setStatus(self::STATUS_SUBSCRIBED);

} else {

$this->setStatus(self::STATUS_NOT_ACTIVE);

}

} else {

$this->setStatus(self::STATUS_SUBSCRIBED);

}

$this->setSubscriberEmail($email);

}

if ($isSubscribeOwnEmail) {

try {

$customer = $this->customerRepository->getById($this->_customerSession->getCustomerId());

$this->setStoreId($customer->getStoreId());

$this->setCustomerId($customer->getId());

} catch (NoSuchEntityException $e) {

$this->setStoreId($this->_storeManager->getStore()->getId());

$this->setCustomerId(0);

}

} else {

$this->setStoreId($this->_storeManager->getStore()->getId());

$this->setCustomerId(0);

}

$this->setStatusChanged(true);

try {

$this->save();

if ($isConfirmNeed === true

&& $isOwnSubscribes === false

) {

$this->sendConfirmationRequestEmail();

} else {

$this->sendConfirmationSuccessEmail();

}

return $this->getStatus();

} catch (\Exception $e) {

throw new \Exception($e->getMessage());

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值