Skip to content

Commit 77496c4

Browse files
committed
MAGETWO-89238: [Sales email] Disabled invoice emails produce performance issue
1 parent 580b7c4 commit 77496c4

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

app/code/Magento/Store/Model/Group.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,12 +414,12 @@ public function beforeDelete()
414414
*/
415415
public function afterDelete()
416416
{
417-
$this->_storeManager->reinitStores();
418417
$group = $this;
419418
$this->getResource()->addCommitCallback(function () use ($group) {
420419
$this->_storeManager->reinitStores();
421420
$this->eventManager->dispatch($this->_eventPrefix . '_delete', ['group' => $group]);
422421
});
422+
$result = parent::afterDelete();
423423

424424
if ($this->getId() === $this->getWebsite()->getDefaultGroupId()) {
425425
$ids = $this->getWebsite()->getGroupIds();
@@ -432,15 +432,14 @@ public function afterDelete()
432432
$this->getWebsite()->setDefaultGroupId($defaultId);
433433
$this->getWebsite()->save();
434434
}
435-
return parent::afterDelete();
435+
return $result;
436436
}
437437

438438
/**
439439
* @inheritdoc
440440
*/
441441
public function afterSave()
442442
{
443-
$this->_storeManager->reinitStores();
444443
$group = $this;
445444
$this->getResource()->addCommitCallback(function () use ($group) {
446445
$this->_storeManager->reinitStores();

app/code/Magento/Store/Model/Store.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,6 @@ public function getWebsiteId()
10561056
*/
10571057
public function afterSave()
10581058
{
1059-
$this->_storeManager->reinitStores();
10601059
if ($this->isObjectNew()) {
10611060
$event = $this->_eventPrefix . '_add';
10621061
} else {
@@ -1247,6 +1246,11 @@ public function beforeDelete()
12471246
*/
12481247
public function afterDelete()
12491248
{
1249+
$store = $this;
1250+
$this->getResource()->addCommitCallback(function () use ($store) {
1251+
$this->_storeManager->reinitStores();
1252+
$this->eventManager->dispatch($this->_eventPrefix . '_delete', ['store' => $store]);
1253+
});
12501254
parent::afterDelete();
12511255
$this->_configCacheType->clean();
12521256

@@ -1261,11 +1265,7 @@ public function afterDelete()
12611265
$this->getGroup()->setDefaultStoreId($defaultId);
12621266
$this->getGroup()->save();
12631267
}
1264-
$store = $this;
1265-
$this->getResource()->addCommitCallback(function () use ($store) {
1266-
$this->_storeManager->reinitStores();
1267-
$this->eventManager->dispatch($this->_eventPrefix . '_delete', ['store' => $store]);
1268-
});
1268+
12691269
return $this;
12701270
}
12711271

0 commit comments

Comments
 (0)