mc-magento2 icon indicating copy to clipboard operation
mc-magento2 copied to clipboard

Magento subscription email sent despite 'Magento always managed emails' set to 'No'

Open itmsenior opened this issue 2 years ago • 1 comments

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

  1. Login to Magento website with customer account.
  2. Go to manage newsletter subscription
  3. Tick box to subscribe to newsletter

Expected result

  1. Customer is subscribed
  2. Magento confirmation email is not sent

Actual result

  1. Customer is subscribed
  2. Magento confirmation email is sent

itmsenior avatar Nov 18 '21 11:11 itmsenior

Update: It looks like the email may only be sent on the second subscription e.g.

  1. Login to Magento website with customer account.
  2. Go to manage newsletter subscription
  3. Tick box to subscribe to newsletter
  4. Go back to manage newsletter subscription
  5. Tick box to unsubscribe from newsletter
  6. Go back to manage newsletter subscription
  7. Re-subscribe to newsletter
  8. Core subscription email wrongly sent.

itmsenior avatar Dec 07 '21 17:12 itmsenior

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?

sprankhub avatar Apr 19 '23 12:04 sprankhub

@gonzaloebiz, any news on this? Thanks!

sprankhub avatar Jun 19 '23 08:06 sprankhub

@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.

itmsenior avatar Jun 19 '23 11:06 itmsenior

@gonzaloebiz, could you have a look at this? Thanks!

sprankhub avatar Jul 26 '23 14:07 sprankhub

@gonzaloebiz, could you release a new version with this fix? Thanks!

sprankhub avatar Sep 15 '23 12:09 sprankhub

Already in 10x.x.57

gonzaloebiz avatar Sep 15 '23 12:09 gonzaloebiz