One of the plugins in this module, which injects into customer extension attributes, breaks signing up for the newsletter when registering a customer account:
|
$subscriber = $this->subscriberResource->loadBySubscriberEmail( |
|
$customer->getEmail(), |
|
(int)$this->storeManager->getStore($customer->getStoreId())->getWebsiteId() |
|
); |
|
|
|
$subscriberStatus = !empty($subscriber['subscriber_status']) ? (int)$subscriber['subscriber_status'] : 0; |
|
$isSubscribed = $subscriberStatus === SubscriberModel::STATUS_SUBSCRIBED; |
|
$extension->setIsSubscribed($isSubscribed); |
|
$customer->setExtensionAttributes($extension); |
When creating an account, is_subscribed is set to 1. Currently this code sets it to 0 as $subscriber is empty, which prevents signing up for the newsletter later on in the code.
To fix this, after loading $subscriber, we need to check whether the array has data. If it doesn't, then we return $extension:
diff --git a/Extensions/Customer.php b/Extensions/Customer.php
--- a/Extensions/Customer.php (revision 356cfc294b35b7fb212224c805978fd98b92abee)
+++ b/Extensions/Customer.php (date 1771242539606)
@@ -44,6 +44,10 @@
(int)$this->storeManager->getStore($customer->getStoreId())->getWebsiteId()
);
+ if (!isset($subscriber['subscriber_id'])) {
+ return $extension;
+ }
+
$subscriberStatus = !empty($subscriber['subscriber_status']) ? (int)$subscriber['subscriber_status'] : 0;
$isSubscribed = $subscriberStatus === SubscriberModel::STATUS_SUBSCRIBED;
$extension->setIsSubscribed($isSubscribed);
One of the plugins in this module, which injects into customer extension attributes, breaks signing up for the newsletter when registering a customer account:
magento/Extensions/Customer.php
Lines 42 to 50 in fb9f5f9
When creating an account,
is_subscribedis set to 1. Currently this code sets it to0as$subscriberis empty, which prevents signing up for the newsletter later on in the code.To fix this, after loading
$subscriber, we need to check whether the array has data. If it doesn't, then we return$extension: