Skip to content

Commit 8ed9266

Browse files
author
Serhiy Zhovnir
committed
#21786 Fix asynchronous email sending for the sales entities which were created with disabled email sending
1 parent 7b1cd79 commit 8ed9266

File tree

12 files changed

+27
-24
lines changed

12 files changed

+27
-24
lines changed

app/code/Magento/Sales/Model/Order/Creditmemo/Sender/EmailSender.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function send(
9696
\Magento\Sales\Api\Data\CreditmemoCommentCreationInterface $comment = null,
9797
$forceSyncMode = false
9898
) {
99-
$creditmemo->setSendEmail(true);
99+
$creditmemo->setSendEmail($this->identityContainer->isEnabled());
100100

101101
if (!$this->globalConfig->getValue('sales_email/general/async_sending') || $forceSyncMode) {
102102
$transport = [

app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoSender.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function __construct(
9999
*/
100100
public function send(Creditmemo $creditmemo, $forceSyncMode = false)
101101
{
102-
$creditmemo->setSendEmail(true);
102+
$creditmemo->setSendEmail($this->identityContainer->isEnabled());
103103

104104
if (!$this->globalConfig->getValue('sales_email/general/async_sending') || $forceSyncMode) {
105105
$order = $creditmemo->getOrder();

app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceSender.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function __construct(
9999
*/
100100
public function send(Invoice $invoice, $forceSyncMode = false)
101101
{
102-
$invoice->setSendEmail(true);
102+
$invoice->setSendEmail($this->identityContainer->isEnabled());
103103

104104
if (!$this->globalConfig->getValue('sales_email/general/async_sending') || $forceSyncMode) {
105105
$order = $invoice->getOrder();

app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentSender.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function __construct(
9999
*/
100100
public function send(Shipment $shipment, $forceSyncMode = false)
101101
{
102-
$shipment->setSendEmail(true);
102+
$shipment->setSendEmail($this->identityContainer->isEnabled());
103103

104104
if (!$this->globalConfig->getValue('sales_email/general/async_sending') || $forceSyncMode) {
105105
$order = $shipment->getOrder();

app/code/Magento/Sales/Model/Order/Invoice/Sender/EmailSender.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function send(
9696
\Magento\Sales\Api\Data\InvoiceCommentCreationInterface $comment = null,
9797
$forceSyncMode = false
9898
) {
99-
$invoice->setSendEmail(true);
99+
$invoice->setSendEmail($this->identityContainer->isEnabled());
100100

101101
if (!$this->globalConfig->getValue('sales_email/general/async_sending') || $forceSyncMode) {
102102
$transport = [

app/code/Magento/Sales/Model/Order/Shipment/Sender/EmailSender.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function send(
9696
\Magento\Sales\Api\Data\ShipmentCommentCreationInterface $comment = null,
9797
$forceSyncMode = false
9898
) {
99-
$shipment->setSendEmail(true);
99+
$shipment->setSendEmail($this->identityContainer->isEnabled());
100100

101101
if (!$this->globalConfig->getValue('sales_email/general/async_sending') || $forceSyncMode) {
102102
$transport = [

app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Sender/EmailSenderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public function testSend($configValue, $forceSyncMode, $isComment, $emailSending
249249

250250
$this->creditmemoMock->expects($this->once())
251251
->method('setSendEmail')
252-
->with(true);
252+
->with($emailSendingResult);
253253

254254
if (!$configValue || $forceSyncMode) {
255255
$transport = [
@@ -279,7 +279,7 @@ public function testSend($configValue, $forceSyncMode, $isComment, $emailSending
279279
->method('setTemplateVars')
280280
->with($transport->getData());
281281

282-
$this->identityContainerMock->expects($this->once())
282+
$this->identityContainerMock->expects($this->exactly(2))
283283
->method('isEnabled')
284284
->willReturn($emailSendingResult);
285285

app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/CreditmemoSenderTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function testSend($configValue, $forceSyncMode, $customerNoteNotify, $ema
9090

9191
$this->creditmemoMock->expects($this->once())
9292
->method('setSendEmail')
93-
->with(true);
93+
->with($emailSendingResult);
9494

9595
$this->globalConfig->expects($this->once())
9696
->method('getValue')
@@ -130,7 +130,7 @@ public function testSend($configValue, $forceSyncMode, $customerNoteNotify, $ema
130130
]
131131
);
132132

133-
$this->identityContainerMock->expects($this->once())
133+
$this->identityContainerMock->expects($this->exactly(2))
134134
->method('isEnabled')
135135
->willReturn($emailSendingResult);
136136

@@ -197,6 +197,9 @@ public function sendDataProvider()
197197
* @param bool $isVirtualOrder
198198
* @param int $formatCallCount
199199
* @param string|null $expectedShippingAddress
200+
* @param bool $emailSendingResult
201+
*
202+
* @return void
200203
* @dataProvider sendVirtualOrderDataProvider
201204
*/
202205
public function testSendVirtualOrder($isVirtualOrder, $formatCallCount, $expectedShippingAddress)
@@ -207,7 +210,7 @@ public function testSendVirtualOrder($isVirtualOrder, $formatCallCount, $expecte
207210

208211
$this->creditmemoMock->expects($this->once())
209212
->method('setSendEmail')
210-
->with(true);
213+
->with(false);
211214

212215
$this->globalConfig->expects($this->once())
213216
->method('getValue')
@@ -242,7 +245,7 @@ public function testSendVirtualOrder($isVirtualOrder, $formatCallCount, $expecte
242245
]
243246
);
244247

245-
$this->identityContainerMock->expects($this->once())
248+
$this->identityContainerMock->expects($this->exactly(2))
246249
->method('isEnabled')
247250
->willReturn(false);
248251

app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/InvoiceSenderTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function testSend($configValue, $forceSyncMode, $customerNoteNotify, $ema
9090

9191
$this->invoiceMock->expects($this->once())
9292
->method('setSendEmail')
93-
->with(true);
93+
->with($emailSendingResult);
9494

9595
$this->globalConfig->expects($this->once())
9696
->method('getValue')
@@ -136,7 +136,7 @@ public function testSend($configValue, $forceSyncMode, $customerNoteNotify, $ema
136136
]
137137
);
138138

139-
$this->identityContainerMock->expects($this->once())
139+
$this->identityContainerMock->expects($this->exactly(2))
140140
->method('isEnabled')
141141
->willReturn($emailSendingResult);
142142

@@ -212,7 +212,7 @@ public function testSendVirtualOrder($isVirtualOrder, $formatCallCount, $expecte
212212

213213
$this->invoiceMock->expects($this->once())
214214
->method('setSendEmail')
215-
->with(true);
215+
->with(false);
216216

217217
$this->globalConfig->expects($this->once())
218218
->method('getValue')
@@ -247,7 +247,7 @@ public function testSendVirtualOrder($isVirtualOrder, $formatCallCount, $expecte
247247
]
248248
);
249249

250-
$this->identityContainerMock->expects($this->once())
250+
$this->identityContainerMock->expects($this->exactly(2))
251251
->method('isEnabled')
252252
->willReturn(false);
253253

app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/ShipmentSenderTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function testSend($configValue, $forceSyncMode, $customerNoteNotify, $ema
9090

9191
$this->shipmentMock->expects($this->once())
9292
->method('setSendEmail')
93-
->with(true);
93+
->with($emailSendingResult);
9494

9595
$this->globalConfig->expects($this->once())
9696
->method('getValue')
@@ -136,7 +136,7 @@ public function testSend($configValue, $forceSyncMode, $customerNoteNotify, $ema
136136
]
137137
);
138138

139-
$this->identityContainerMock->expects($this->once())
139+
$this->identityContainerMock->expects($this->exactly(2))
140140
->method('isEnabled')
141141
->willReturn($emailSendingResult);
142142

@@ -212,7 +212,7 @@ public function testSendVirtualOrder($isVirtualOrder, $formatCallCount, $expecte
212212

213213
$this->shipmentMock->expects($this->once())
214214
->method('setSendEmail')
215-
->with(true);
215+
->with(false);
216216

217217
$this->globalConfig->expects($this->once())
218218
->method('getValue')
@@ -247,7 +247,7 @@ public function testSendVirtualOrder($isVirtualOrder, $formatCallCount, $expecte
247247
]
248248
);
249249

250-
$this->identityContainerMock->expects($this->once())
250+
$this->identityContainerMock->expects($this->exactly(2))
251251
->method('isEnabled')
252252
->willReturn(false);
253253
$this->shipmentResourceMock->expects($this->once())

0 commit comments

Comments
 (0)