Skip to content

Commit 2014391

Browse files
author
Oleksii Korshenko
authored
ENGCOM-2444: Resolve incorrect scope code selection when the requested scopeCode is null #16940
2 parents 6c7bb10 + 83ab2ef commit 2014391

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,11 @@ public function getWebsites($withDefault = false, $codeKey = false)
234234
public function reinitStores()
235235
{
236236
$this->currentStoreId = null;
237-
$this->cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, [StoreResolver::CACHE_TAG, Store::CACHE_TAG]);
238-
$this->scopeConfig->clean();
239237
$this->storeRepository->clean();
240238
$this->websiteRepository->clean();
241239
$this->groupRepository->clean();
240+
$this->cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, [StoreResolver::CACHE_TAG, Store::CACHE_TAG]);
241+
$this->scopeConfig->clean();
242242
}
243243

244244
/**

lib/internal/Magento/Framework/App/Config/ScopeCodeResolver.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Framework\App\Config;
77

8+
use Magento\Framework\App\ScopeInterface;
89
use Magento\Framework\App\ScopeResolverPool;
910

1011
/**
@@ -34,28 +35,32 @@ public function __construct(ScopeResolverPool $scopeResolverPool)
3435
* Resolve scope code
3536
*
3637
* @param string $scopeType
37-
* @param string $scopeCode
38+
* @param string|null $scopeCode
3839
* @return string
3940
*/
4041
public function resolve($scopeType, $scopeCode)
4142
{
4243
if (isset($this->resolvedScopeCodes[$scopeType][$scopeCode])) {
4344
return $this->resolvedScopeCodes[$scopeType][$scopeCode];
4445
}
45-
if (($scopeCode === null || is_numeric($scopeCode))
46-
&& $scopeType !== ScopeConfigInterface::SCOPE_TYPE_DEFAULT
47-
) {
46+
47+
if ($scopeType !== ScopeConfigInterface::SCOPE_TYPE_DEFAULT) {
4848
$scopeResolver = $this->scopeResolverPool->get($scopeType);
4949
$resolverScopeCode = $scopeResolver->getScope($scopeCode);
5050
} else {
5151
$resolverScopeCode = $scopeCode;
5252
}
5353

54-
if ($resolverScopeCode instanceof \Magento\Framework\App\ScopeInterface) {
54+
if ($resolverScopeCode instanceof ScopeInterface) {
5555
$resolverScopeCode = $resolverScopeCode->getCode();
5656
}
5757

58+
if ($scopeCode === null) {
59+
$scopeCode = $resolverScopeCode;
60+
}
61+
5862
$this->resolvedScopeCodes[$scopeType][$scopeCode] = $resolverScopeCode;
63+
5964
return $resolverScopeCode;
6065
}
6166

0 commit comments

Comments
 (0)