Skip to content

Commit f001e23

Browse files
author
mastiuhin-olexandr
committed
MC-24772: After choosing "Web Site" as default, where the "Store View" is disabled, the website is crashing
1 parent 1c3837c commit f001e23

File tree

1 file changed

+13
-0
lines changed
  • app/code/Magento/Backend/Controller/Adminhtml/System/Store

1 file changed

+13
-0
lines changed

app/code/Magento/Backend/Controller/Adminhtml/System/Store/Save.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ private function processWebsiteSave($postData)
3333
$websiteModel->setId(null);
3434
}
3535

36+
$groupModel = $this->_objectManager->create(\Magento\Store\Model\Group::class);
37+
$groupModel->load($websiteModel->getDefaultGroupId());
38+
39+
$storeModel = $this->_objectManager->create(\Magento\Store\Model\Store::class);
40+
$storeModel->load($groupModel->getDefaultStoreId());
41+
42+
if ($websiteModel->getIsDefault() && !$storeModel->isActive()) {
43+
throw new \Magento\Framework\Exception\LocalizedException(
44+
__("Please enable your Store View before using this Web Site as Default")
45+
);
46+
}
47+
3648
$websiteModel->save();
3749
$this->messageManager->addSuccessMessage(__('You saved the website.'));
3850

@@ -99,6 +111,7 @@ private function processGroupSave($postData)
99111
__('An inactive store view cannot be saved as default store view')
100112
);
101113
}
114+
102115
$groupModel->save();
103116
$this->messageManager->addSuccessMessage(__('You saved the store.'));
104117

0 commit comments

Comments
 (0)