mc-magento2
mc-magento2 copied to clipboard
Magento subscription email sent despite 'Magento always managed emails' set to 'No'
Hi,
As per title, I've checked similar issue #1189 but I believe I'm on the 2.4 branch so I think this is a new occurrence of this bug.
Preconditions
- Magento 2.4.3-p1
- Mailchimp 103.4.43
- Config 'Magento always manage emails' set to 'No'
Steps to reproduce
- Login to Magento website with customer account.
- Go to manage newsletter subscription
- Tick box to subscribe to newsletter
Expected result
- Customer is subscribed
- Magento confirmation email is not sent
Actual result
- Customer is subscribed
- Magento confirmation email is sent
Update: It looks like the email may only be sent on the second subscription e.g.
- Login to Magento website with customer account.
- Go to manage newsletter subscription
- Tick box to subscribe to newsletter
- Go back to manage newsletter subscription
- Tick box to unsubscribe from newsletter
- Go back to manage newsletter subscription
- Re-subscribe to newsletter
- Core subscription email wrongly sent.
This still seems to happen with Magento 2.4.5-p2, PHP 8.1, Mailchimp 103.4.49. There is already a PR, which might fix it. @gonzaloebiz, could you have a look?
@gonzaloebiz, any news on this? Thanks!
@sprankhub
Just to mention we're now using a slightly modified afterLoadByCustomer function that matches the recent changes to afterLoadBySubscriberEmail.
/**
* @param \Magento\Newsletter\Model\Subscriber $subscriber
* @param $email
* @param $websiteId
* @return \Magento\Newsletter\Model\Subscriber
*/
public function afterLoadByCustomer(\Magento\Newsletter\Model\Subscriber $subscriber, $email, $websiteId)
{
if ($this->_helper->isMailChimpEnabled($subscriber->getStoreId())) {
try {
if (!$this->_helper->getConfigValue(
\Ebizmarts\MailChimp\Helper\Data::XML_MAGENTO_MAIL,
$subscriber->getStoreId()
)) {
$subscriber->setImportMode(true);
}
} catch (\Exception $exception) {
$this->_helper->log($exception->getMessage());
}
}
return $subscriber;
}
Our CR is likely to out of date to be usable now and I can also see that Subscriber.php appears to have been rewritten in the development branch.
@gonzaloebiz, could you have a look at this? Thanks!
@gonzaloebiz, could you release a new version with this fix? Thanks!
Already in 10x.x.57