Is there any way to stop to sending email to customer while importing customer ?
Is Disable Email Communication : OFF
this helpful for that ?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityIf 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.
<?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
);
}
}