1

I have multiple store view setup in my Magento 2 store.

Now I want to disable welcome email for the user that register from the wholesale store. I am trying this solution but it stops sending email to all user.

https://magento.stackexchange.com/a/174419

I am not getting how to do this for the specific store.

Update

I am trying following code

<?php

namespace Company\Module\Model\Plugin;

class EmailNotification extends \Magento\Customer\Model\EmailNotification {

    public function aroundNewAccount(
        \Magento\Customer\Model\EmailNotification $subject,
        \Closure $proceed,
        \Magento\Customer\Api\Data\CustomerInterface $customer,
        $type,
        $backUrl = '',
        $storeId = 0,
        $sendemailStoreId = null
    ) {

        if($sendemailStoreId == 1){
            return false;
        }

        /*$_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $_storeManager = $_objectManager->get('Magento\Store\Model\StoreManager');
        if($_storeManager->getStore()->getWebsiteId() == 1){
            return false;
        }*/

        $result = $proceed($customer ,$type ,$backUrl ,$storeId ,$sendemailStoreId);
        return $result; 
    }

}

?>

And getting error We can't save the customer.

Thanks,

3

You should use the create the plugin for the class

Magento\Customer\Model\EmailNotification You need to create plugin on newAccount.

create around method aroundNewAccount() on newAccount() and stop the mail send depend on your store.

public function aroundNewAccount(
        \Magento\Customer\Model\EmailNotification $subject
        \Closure $proceed,
        \Magento\Customer\Api\Data\CustomerInterface $customer,
        $type,
        $backUrl,
        $storeId,
        $sendemailStoreId
    ) {
        if($sendemailStoreId != {YourWHoleSalesStorId}){
            $result = $proceed($customer ,$type ,$backUrl ,$storeId ,$sendemailStoreId);
            return $result
        }

    }
  • Hello Amit, Thanks for the answer. I have tried your code and getting error We can't save the customer. But customer already saved when i check in admin. – Hardik Apr 12 '18 at 7:57
  • make return false to return.updated the answer – Amit Bera Apr 12 '18 at 8:18
  • Same error again We can't save the customer. – Hardik Apr 12 '18 at 8:21
  • Ok, will check the code. – Amit Bera Apr 12 '18 at 8:39
  • Thanks, Btw its giving error in front but user is created when checking in admin. – Hardik Apr 12 '18 at 9:13
0

Do we need to extend the class \Magento\Customer\Model\EmailNotification in our olugin class as when i extended this class started getting error We > can't save the customer. If not extending the class then new account email are not sent in all the cases and we need to disable new account email communication for wholesale store only

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.