0

Can anyone let me know how can I Over write EmailNotification File in our custom module.

I tried this way by modifying methods of

private function sendEmailTemplate(
        $customer,
        $template,
        $sender,
        $templateParams = [],
        $storeId = null,
        $email = null
    ) {
        $templateId = $this->scopeConfig->getValue($template, 'store', $storeId);
        if ($email === null) {
            $email = $customer->getEmail();
        }
        $transport = $this->transportBuilder->setTemplateIdentifier($templateId)
            ->setTemplateOptions(['area' => 'frontend', 'store' => $storeId])
            ->setTemplateVars($templateParams)
            ->setFrom($this->scopeConfig->getValue($sender, 'store', $storeId))
            ->addTo($email, $this->customerViewHelper->getCustomerName($customer))
            ->addBcc('abcd@gmail.com')
            ->getTransport();

        $transport->sendMessage();
    }

I am trying this way to override Model Class: di.xml

<?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\Customer\Model\EmailNotification"
                type="TrainingJaymin\AdminEmail\Model\EmailNotification" />
</config>

Is there anything else I need to do?

Because error says Invalid EmailNotificationInterface

Any help will be appreciated

1
  • I am sure you had run setup di compile command – kunj May 12 '20 at 15:52

Your Answer

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

Browse other questions tagged or ask your own question.