File tree Expand file tree Collapse file tree 2 files changed +15
-32
lines changed Expand file tree Collapse file tree 2 files changed +15
-32
lines changed Original file line number Diff line number Diff line change @@ -132,20 +132,11 @@ public function sendEmails()
132
132
133
133
/** @var \Magento\Sales\Model\AbstractModel $item */
134
134
foreach ($ entityCollection ->getItems () as $ item ) {
135
- if ($ this ->emailSender ->send ($ item , true )) {
136
- $ this ->entityResource ->saveAttribute (
137
- $ item ->setEmailSent (true ),
138
- 'email_sent '
139
- );
140
- } else {
141
- // When the email is failed to send, the email_sent attribute
142
- // should be set to false, preventing this email from being
143
- // sent over and over again in the next cron runs.
144
- $ this ->entityResource ->saveAttribute (
145
- $ item ->setEmailSent (false ),
146
- 'email_sent '
147
- );
148
- }
135
+ $ isEmailSent = $ this ->emailSender ->send ($ item , true );
136
+ $ this ->entityResource ->saveAttribute (
137
+ $ item ->setEmailSent ($ isEmailSent ),
138
+ 'email_sent '
139
+ );
149
140
}
150
141
}
151
142
}
Original file line number Diff line number Diff line change @@ -245,24 +245,16 @@ public function testExecute(
245
245
->method ('isEnabled ' )
246
246
->willReturn (true );
247
247
248
- if ($ emailSendingResult ) {
249
- $ collectionItem
250
- ->expects ($ this ->once ())
251
- ->method ('setEmailSent ' )
252
- ->with (true )
253
- ->willReturn ($ collectionItem );
254
-
255
- $ this ->entityResource
256
- ->expects ($ this ->once ())
257
- ->method ('saveAttribute ' )
258
- ->with ($ collectionItem );
259
- } else {
260
- $ collectionItem
261
- ->expects ($ this ->once ())
262
- ->method ('setEmailSent ' )
263
- ->with (false )
264
- ->willReturn ($ collectionItem );
265
- }
248
+ $ collectionItem
249
+ ->expects ($ this ->once ())
250
+ ->method ('setEmailSent ' )
251
+ ->with ($ emailSendingResult )
252
+ ->willReturn ($ collectionItem );
253
+
254
+ $ this ->entityResource
255
+ ->expects ($ this ->once ())
256
+ ->method ('saveAttribute ' )
257
+ ->with ($ collectionItem );
266
258
}
267
259
}
268
260
You can’t perform that action at this time.
0 commit comments