Override SenderBuilder class to add Bcc when sending invoiceCE 1.8.1 invoice mail event hookSend Copy of Order Confirmation email programmatically in magento 2Magento 2 Plugin missing argument 2Magento 2: How to override newsletter Subscriber modelOverride new order email in magento 2Override model function Magento 2Magento 2 add prefix in Invoice numberMagento 2.2.5: Overriding Admin Controller sales/orderMagento2 : Remove shipping charge and credit cart type and number from order invoiceget invoice item using order_item_id in magento 2
Discriminated by senior researcher because of my ethnicity
Two field separators (colon and space) in awk
How could Tony Stark make this in Endgame?
Elements that can bond to themselves?
Checks user level and limit the data before saving it to mongoDB
Why was the Spitfire's elliptical wing almost uncopied by other aircraft of World War 2?
How much cash can I safely carry into the USA and avoid civil forfeiture?
What happens to Mjolnir (Thor's hammer) at the end of Endgame?
Why didn't the Space Shuttle bounce back into space as many times as possible so as to lose a lot of kinetic energy up there?
What is the philosophical significance of speech acts/implicature?
Implications of cigar-shaped bodies having rings?
Betweenness centrality formula
How do I deal with a coworker that keeps asking to make small superficial changes to a report, and it is seriously triggering my anxiety?
Can an Area of Effect spell cast outside a Prismatic Wall extend inside it?
Can someone publish a story that happened to you?
How to fry ground beef so it is well-browned
Critique of timeline aesthetic
Is there really no use for MD5 anymore?
How to limit Drive Letters Windows assigns to new removable USB drives
Alignment of various blocks in tikz
Can we say “you can pay when the order gets ready”?
What happened to Captain America in Endgame?
"You've called the wrong number" or "You called the wrong number"
Don’t seats that recline flat defeat the purpose of having seatbelts?
Override SenderBuilder class to add Bcc when sending invoice
CE 1.8.1 invoice mail event hookSend Copy of Order Confirmation email programmatically in magento 2Magento 2 Plugin missing argument 2Magento 2: How to override newsletter Subscriber modelOverride new order email in magento 2Override model function Magento 2Magento 2 add prefix in Invoice numberMagento 2.2.5: Overriding Admin Controller sales/orderMagento2 : Remove shipping charge and credit cart type and number from order invoiceget invoice item using order_item_id in magento 2
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I didn't found an event when invoice email is sent, so i tried to override MagentoSalesModelOrderEmailSenderBuilder class, the override is working but getting the customer attribute 'invoice_email' is not working, it works on my localhost by in the development website (which is multistore), it didn't work.
I don't know if there's a better solution to use an observer if there's a sending invoice email event
so in my module
Vendor/ModuleName/etc/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="MagentoSalesModelOrderEmailSenderBuilder" type="VendorModuleNameModelSalesOrderEmailSenderBuilder" />
</config>
In app/code/Vendor/ModuleName/Model/Sales/Order/Email/SenderBuilder.php
namespace WetagInvoiceEmailModelSalesOrderEmail;
class SenderBuilder extends MagentoSalesModelOrderEmailSenderBuilder
public function send()
$this->configureEmailTemplate();
$this->transportBuilder->addTo(
$this->identityContainer->getCustomerEmail(),
$this->identityContainer->getCustomerName()
);
$copyTo = $this->identityContainer->getEmailCopyTo();
if (!empty($copyTo) && $this->identityContainer->getCopyMethod() == 'bcc')
foreach ($copyTo as $email)
$this->transportBuilder->addBcc($email);
if($this->identityContainer instanceof MagentoSalesModelOrderEmailContainerInvoiceIdentity)
//do stuff
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$CustomerModel = $objectManager->create('MagentoCustomerModelCustomer');
$CustomerModel->setWebsiteId($this->identityContainer->getStore()->getStoreId());
$CustomerModel->loadByEmail($this->identityContainer->getCustomerEmail());
$email = $CustomerModel->getData()['invoice_email'];
if(!empty($email))
$this->transportBuilder->addBcc($email);
$transport = $this->transportBuilder->getTransport();
$transport->sendMessage();
magento2 event-observer email overrides invoice
add a comment |
I didn't found an event when invoice email is sent, so i tried to override MagentoSalesModelOrderEmailSenderBuilder class, the override is working but getting the customer attribute 'invoice_email' is not working, it works on my localhost by in the development website (which is multistore), it didn't work.
I don't know if there's a better solution to use an observer if there's a sending invoice email event
so in my module
Vendor/ModuleName/etc/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="MagentoSalesModelOrderEmailSenderBuilder" type="VendorModuleNameModelSalesOrderEmailSenderBuilder" />
</config>
In app/code/Vendor/ModuleName/Model/Sales/Order/Email/SenderBuilder.php
namespace WetagInvoiceEmailModelSalesOrderEmail;
class SenderBuilder extends MagentoSalesModelOrderEmailSenderBuilder
public function send()
$this->configureEmailTemplate();
$this->transportBuilder->addTo(
$this->identityContainer->getCustomerEmail(),
$this->identityContainer->getCustomerName()
);
$copyTo = $this->identityContainer->getEmailCopyTo();
if (!empty($copyTo) && $this->identityContainer->getCopyMethod() == 'bcc')
foreach ($copyTo as $email)
$this->transportBuilder->addBcc($email);
if($this->identityContainer instanceof MagentoSalesModelOrderEmailContainerInvoiceIdentity)
//do stuff
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$CustomerModel = $objectManager->create('MagentoCustomerModelCustomer');
$CustomerModel->setWebsiteId($this->identityContainer->getStore()->getStoreId());
$CustomerModel->loadByEmail($this->identityContainer->getCustomerEmail());
$email = $CustomerModel->getData()['invoice_email'];
if(!empty($email))
$this->transportBuilder->addBcc($email);
$transport = $this->transportBuilder->getTransport();
$transport->sendMessage();
magento2 event-observer email overrides invoice
add a comment |
I didn't found an event when invoice email is sent, so i tried to override MagentoSalesModelOrderEmailSenderBuilder class, the override is working but getting the customer attribute 'invoice_email' is not working, it works on my localhost by in the development website (which is multistore), it didn't work.
I don't know if there's a better solution to use an observer if there's a sending invoice email event
so in my module
Vendor/ModuleName/etc/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="MagentoSalesModelOrderEmailSenderBuilder" type="VendorModuleNameModelSalesOrderEmailSenderBuilder" />
</config>
In app/code/Vendor/ModuleName/Model/Sales/Order/Email/SenderBuilder.php
namespace WetagInvoiceEmailModelSalesOrderEmail;
class SenderBuilder extends MagentoSalesModelOrderEmailSenderBuilder
public function send()
$this->configureEmailTemplate();
$this->transportBuilder->addTo(
$this->identityContainer->getCustomerEmail(),
$this->identityContainer->getCustomerName()
);
$copyTo = $this->identityContainer->getEmailCopyTo();
if (!empty($copyTo) && $this->identityContainer->getCopyMethod() == 'bcc')
foreach ($copyTo as $email)
$this->transportBuilder->addBcc($email);
if($this->identityContainer instanceof MagentoSalesModelOrderEmailContainerInvoiceIdentity)
//do stuff
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$CustomerModel = $objectManager->create('MagentoCustomerModelCustomer');
$CustomerModel->setWebsiteId($this->identityContainer->getStore()->getStoreId());
$CustomerModel->loadByEmail($this->identityContainer->getCustomerEmail());
$email = $CustomerModel->getData()['invoice_email'];
if(!empty($email))
$this->transportBuilder->addBcc($email);
$transport = $this->transportBuilder->getTransport();
$transport->sendMessage();
magento2 event-observer email overrides invoice
I didn't found an event when invoice email is sent, so i tried to override MagentoSalesModelOrderEmailSenderBuilder class, the override is working but getting the customer attribute 'invoice_email' is not working, it works on my localhost by in the development website (which is multistore), it didn't work.
I don't know if there's a better solution to use an observer if there's a sending invoice email event
so in my module
Vendor/ModuleName/etc/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="MagentoSalesModelOrderEmailSenderBuilder" type="VendorModuleNameModelSalesOrderEmailSenderBuilder" />
</config>
In app/code/Vendor/ModuleName/Model/Sales/Order/Email/SenderBuilder.php
namespace WetagInvoiceEmailModelSalesOrderEmail;
class SenderBuilder extends MagentoSalesModelOrderEmailSenderBuilder
public function send()
$this->configureEmailTemplate();
$this->transportBuilder->addTo(
$this->identityContainer->getCustomerEmail(),
$this->identityContainer->getCustomerName()
);
$copyTo = $this->identityContainer->getEmailCopyTo();
if (!empty($copyTo) && $this->identityContainer->getCopyMethod() == 'bcc')
foreach ($copyTo as $email)
$this->transportBuilder->addBcc($email);
if($this->identityContainer instanceof MagentoSalesModelOrderEmailContainerInvoiceIdentity)
//do stuff
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$CustomerModel = $objectManager->create('MagentoCustomerModelCustomer');
$CustomerModel->setWebsiteId($this->identityContainer->getStore()->getStoreId());
$CustomerModel->loadByEmail($this->identityContainer->getCustomerEmail());
$email = $CustomerModel->getData()['invoice_email'];
if(!empty($email))
$this->transportBuilder->addBcc($email);
$transport = $this->transportBuilder->getTransport();
$transport->sendMessage();
magento2 event-observer email overrides invoice
magento2 event-observer email overrides invoice
asked 6 hours ago
tarek fellahtarek fellah
164
164
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
This was an issue with the store id, it shouldn't to be get from the identityContainer, this is my solution
$url = MagentoFrameworkAppObjectManager::getInstance();
$storeManager = $url->get('MagentoStoreModelStoreManagerInterface');
$websiteId = $storeManager->getWebsite()->getWebsiteId();
// Get Store ID
//$store = $storeManager->getStore();
//$storeId = $store->getStoreId();
$CustomerModel->setWebsiteId($websiteId);
$CustomerModel->loadByEmail($this->identityContainer->getCustomerEmail());
$email = $CustomerModel->getData()['invoice_email'];
Why you use object manager, like MagentoFrameworkAppObjectManager::getInstance()? Don't do this.
– Sohel Rana
4 hours ago
@SohelRana how to do? i'm Magento beginner
– tarek fellah
1 hour ago
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f272636%2foverride-senderbuilder-class-to-add-bcc-when-sending-invoice%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This was an issue with the store id, it shouldn't to be get from the identityContainer, this is my solution
$url = MagentoFrameworkAppObjectManager::getInstance();
$storeManager = $url->get('MagentoStoreModelStoreManagerInterface');
$websiteId = $storeManager->getWebsite()->getWebsiteId();
// Get Store ID
//$store = $storeManager->getStore();
//$storeId = $store->getStoreId();
$CustomerModel->setWebsiteId($websiteId);
$CustomerModel->loadByEmail($this->identityContainer->getCustomerEmail());
$email = $CustomerModel->getData()['invoice_email'];
Why you use object manager, like MagentoFrameworkAppObjectManager::getInstance()? Don't do this.
– Sohel Rana
4 hours ago
@SohelRana how to do? i'm Magento beginner
– tarek fellah
1 hour ago
add a comment |
This was an issue with the store id, it shouldn't to be get from the identityContainer, this is my solution
$url = MagentoFrameworkAppObjectManager::getInstance();
$storeManager = $url->get('MagentoStoreModelStoreManagerInterface');
$websiteId = $storeManager->getWebsite()->getWebsiteId();
// Get Store ID
//$store = $storeManager->getStore();
//$storeId = $store->getStoreId();
$CustomerModel->setWebsiteId($websiteId);
$CustomerModel->loadByEmail($this->identityContainer->getCustomerEmail());
$email = $CustomerModel->getData()['invoice_email'];
Why you use object manager, like MagentoFrameworkAppObjectManager::getInstance()? Don't do this.
– Sohel Rana
4 hours ago
@SohelRana how to do? i'm Magento beginner
– tarek fellah
1 hour ago
add a comment |
This was an issue with the store id, it shouldn't to be get from the identityContainer, this is my solution
$url = MagentoFrameworkAppObjectManager::getInstance();
$storeManager = $url->get('MagentoStoreModelStoreManagerInterface');
$websiteId = $storeManager->getWebsite()->getWebsiteId();
// Get Store ID
//$store = $storeManager->getStore();
//$storeId = $store->getStoreId();
$CustomerModel->setWebsiteId($websiteId);
$CustomerModel->loadByEmail($this->identityContainer->getCustomerEmail());
$email = $CustomerModel->getData()['invoice_email'];
This was an issue with the store id, it shouldn't to be get from the identityContainer, this is my solution
$url = MagentoFrameworkAppObjectManager::getInstance();
$storeManager = $url->get('MagentoStoreModelStoreManagerInterface');
$websiteId = $storeManager->getWebsite()->getWebsiteId();
// Get Store ID
//$store = $storeManager->getStore();
//$storeId = $store->getStoreId();
$CustomerModel->setWebsiteId($websiteId);
$CustomerModel->loadByEmail($this->identityContainer->getCustomerEmail());
$email = $CustomerModel->getData()['invoice_email'];
edited 5 hours ago
answered 5 hours ago
tarek fellahtarek fellah
164
164
Why you use object manager, like MagentoFrameworkAppObjectManager::getInstance()? Don't do this.
– Sohel Rana
4 hours ago
@SohelRana how to do? i'm Magento beginner
– tarek fellah
1 hour ago
add a comment |
Why you use object manager, like MagentoFrameworkAppObjectManager::getInstance()? Don't do this.
– Sohel Rana
4 hours ago
@SohelRana how to do? i'm Magento beginner
– tarek fellah
1 hour ago
Why you use object manager, like MagentoFrameworkAppObjectManager::getInstance()? Don't do this.
– Sohel Rana
4 hours ago
Why you use object manager, like MagentoFrameworkAppObjectManager::getInstance()? Don't do this.
– Sohel Rana
4 hours ago
@SohelRana how to do? i'm Magento beginner
– tarek fellah
1 hour ago
@SohelRana how to do? i'm Magento beginner
– tarek fellah
1 hour ago
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f272636%2foverride-senderbuilder-class-to-add-bcc-when-sending-invoice%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown