Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loadBySubscriberEmail() error registering customer account via checkout #2000

Open
vanmelick opened this issue Sep 9, 2024 · 0 comments
Open

Comments

@vanmelick
Copy link

vanmelick commented Sep 9, 2024

Magento 2.4.7-p1
mailchimp/mc-magento2 103.4.62

In the checkout, when a guest customer indicates he wants to create an account, he is not redirected to the payment service provider page. The order is created in Magento, but the customer is NOT created.

Error message in logs:
main.CRITICAL: TypeError: Magento\Newsletter\Model\Subscriber\Interceptor::loadBySubscriberEmail(): Argument #2 ($websiteId) must be of type int, null given, called in /magento-root-folder/vendor/mailchimp/mc-magento2/Observer/Customer/SaveBefore.php on line 72 and defined in /magento-root-folder/generated/code/Magento/Newsletter/Model/Subscriber/Interceptor.php:20

We applied this patch to fix it:

--- Observer/Customer/SaveBefore.php	2024-09-09 12:12:12.551523556 +0000
+++ Observer/Customer/SaveBefore.php	2024-09-09 12:14:27.428282120 +0000
@@ -26,6 +26,10 @@
      */
     private $syncHelper;
     /**
+     * @var \Magento\Store\Model\StoreManagerInterface
+     */
+    private $_storeManager;
+    /**
      * @var \Magento\Newsletter\Model\SubscriberFactory
      */
     protected $subscriberFactory;
@@ -38,11 +42,13 @@
     public function __construct(
         \Ebizmarts\MailChimp\Helper\Data $helper,
         SyncHelper $syncHelper,
-        \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory
+        \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory,
+        \Magento\Store\Model\StoreManagerInterface $storeManager
     ) {
         $this->_helper              = $helper;
         $this->syncHelper           = $syncHelper;
         $this->subscriberFactory    = $subscriberFactory;
+        $this->_storeManager = $storeManager;
     }
 
     public function execute(\Magento\Framework\Event\Observer $observer)
@@ -52,7 +58,8 @@
          */
         $customer = $observer->getCustomer();
         $storeId  = $customer->getStoreId();
-        $websiteId = $customer->getWebsiteId();
+        $websiteId = $this->_storeManager->getStore()->getWebsiteId();
+
         if ($this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_ACTIVE)) {
             if ($this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_ECOMMERCE_ACTIVE)) {
                 $mailchimpStoreId = $this->_helper->getConfigValue(

However this reverts (in that file) what was merged via #1823

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant