1

Is there any way to stop to sending email to customer while importing customer ?

Is Disable Email Communication : OFF this helpful for that ?

  • How you import the customer? – Amit Bera May 23 '19 at 8:56
1

If you want to stop sending the email during Customer import then you have to work on Magento\Customer\Model\EmailNotification:newAccount().

Create an around plugin on Magento\Customer\Model\EmailNotification:newAccount() method and stop execute of this method.

And add Import Url full Action name as a condition on this plugin.

Plugin Class

<?php

namespace Devamitbera\Systemconfig\Plugin;

use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Customer\Model\EmailNotification as CustomerEmailNotification;

class EmailNotification {

    protected $request;
    public function __construct(
        \Magento\Framework\App\Request\Http $request
    ) {
        $this->request = $request;
    }

    public function aroundNewAccount(
        CustomerEmailNotification $subject,
        \Closure $proceed,    
        CustomerInterface $customer,
        $type = CustomerEmailNotification::NEW_ACCOUNT_EMAIL_REGISTERED,
        $backUrl = '',
        $storeId = 0,
        $sendemailStoreId = null
    ) {

        $action = $this->request->getFullActionName();
        // if import URL  Full Action pathc then  donot excute rest of
        //  all code
        if($action == 'MY_ACTION_FULLNAME'){
            return $subject;
        }
        return $proceed(
                $customer,
                $type,
                $backUrl,
                $storeId,
                $sendemailStoreId
        );
    }
}
|improve this answer|||||
  • I am importing customers using magento's default import feature, How do I stop mail sending during import process – Purushotam Sharma yesterday

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.