Skip to content

Commit b3e91eb

Browse files
committed
MAGE-839 Fix bug with website / store override comparisons
1 parent c5a3676 commit b3e91eb

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

Helper/Configuration/ConfigChecker.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,34 @@ public function __construct(
1616
protected WebsiteRepositoryInterface $websiteRepository
1717
) {}
1818

19-
public function isSettingAppliedForScopeAndCode(string $path, string $scope, string $code): bool
19+
/**
20+
* Is a scoped value different from the default?
21+
* @param string $path
22+
* @param string $scope
23+
* @param mixed $code
24+
* @return bool
25+
*/
26+
public function isSettingAppliedForScopeAndCode(string $path, string $scope, mixed $code): bool
2027
{
2128
$value = $this->scopeConfig->getValue($path, $scope, $code);
2229
$defaultValue = $this->scopeConfig->getValue($path);
2330
return ($value !== $defaultValue);
2431
}
2532

33+
/**
34+
* Does a store config override the website config?
35+
* @param string $path
36+
* @param mixed $websiteId
37+
* @param int $storeId
38+
* @return bool
39+
*/
40+
protected function isStoreSettingOverridingWebsite(string $path, mixed $websiteId, int $storeId): bool
41+
{
42+
$storeValue = $this->scopeConfig->getValue($path, ScopeInterface::SCOPE_STORES, $storeId);
43+
$websiteValue = $this->scopeConfig->getValue($path, ScopeInterface::SCOPE_WEBSITES, $websiteId);
44+
return ($storeValue !== $websiteValue);
45+
}
46+
2647
/**
2748
* For a given path, check if that path has a non-default value
2849
* and if so perform corresponding logic (specified via callback)
@@ -94,9 +115,9 @@ public function getAffectedStoreIds(string $path, string $scope, int $scopeId):
94115
case ScopeInterface::SCOPE_WEBSITES:
95116
$website = $this->websiteRepository->getById($scopeId);
96117
foreach ($website->getStores() as $store) {
97-
if (!$this->isSettingAppliedForScopeAndCode(
118+
if (!$this->isStoreSettingOverridingWebsite(
98119
$path,
99-
ScopeInterface::SCOPE_STORES,
120+
$website->getId(),
100121
$store->getId()
101122
)) {
102123
$storeIds[] = $store->getId();

0 commit comments

Comments
 (0)