Skip to content

Commit 2dac4d1

Browse files
committed
Merge remote-tracking branch 'origin/MC-38925' into 2.4-develop-pr46
2 parents 54dbcfa + 58c1ef5 commit 2dac4d1

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

app/code/Magento/Customer/ViewModel/Customer/Store.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,12 @@ private function getStoreOptionsWithCurrentWebsiteId(): array
113113
if (!empty($this->dataPersistor->get('customer')['account'])) {
114114
$currentWebsiteId = (string)$this->dataPersistor->get('customer')['account']['website_id'];
115115
} else {
116-
$currentWebsiteId = $this->storeManager->getDefaultStoreView()->getWebsiteId();
116+
$defaultStore = $this->storeManager->getDefaultStoreView();
117+
if (!$defaultStore) {
118+
$stores = $this->storeManager->getStores();
119+
$defaultStore = array_shift($stores);
120+
}
121+
$currentWebsiteId = $defaultStore->getWebsiteId();
117122
}
118123

119124
foreach ($options as $key => $option) {

dev/tests/integration/testsuite/Magento/Store/_files/second_website_with_store_group_and_store.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,6 @@
5656
$storeResource->save($store);
5757
/* Refresh CatalogSearch index */
5858
/** @var IndexerRegistry $indexerRegistry */
59+
$storeManager->reinitStores();
5960
$indexerRegistry = $objectManager->get(IndexerRegistry::class);
6061
$indexerRegistry->get(Fulltext::INDEXER_ID)->reindexAll();

0 commit comments

Comments
 (0)