The client requested the ability to deactivate the Company Email notifications sent to customers upon assignment in Adobe Commerce. Unfortunately, this cannot be accomplished through the platform’s default settings. However, you can achieve this programmatically using the following method.
Create a di.xml with preference like a typical overwrite in Magento.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Company\Model\Email\Sender"
type="Bajaj\Enhance\Model\Email\SenderOverride"/>
</config>
Need to override the function that sends the email.
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Bajaj\Enhance\Model\Email;
use Magento\Company\Model\Email\Sender;
/**
* Sending company related emails.
*/
class SenderOverride extends Sender
{
/**
* Send email to customer after assign company to him.
*
* @param \Magento\Customer\Api\Data\CustomerInterface $customer
* @param int $companyId
* @return $this
* @throws \Magento\Framework\Exception\NoSuchEntityException
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function sendCustomerCompanyAssignNotificationEmail(
\Magento\Customer\Api\Data\CustomerInterface $customer,
$companyId
): static {
return $this;
}
}
Similarly, you can disable any email sent from the Company B2B module.
- sendRemoveSuperUserNotificationEmail
- sendInactivateSuperUserNotificationEmail
- sendSalesRepresentativeNotificationEmail
- sendAdminNotificationEmail
- sendCompanyStatusChangeNotificationEmail
- sendUserStatusChangeNotificationEmail
Hope this helps. Please share your feedback in the comment box below.