Skip to content

Commit ff7ddc0

Browse files
committed
MAGE-848 Swap cache clean for config reinitialization
1 parent ee4f8e7 commit ff7ddc0

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

Console/Command/ReplicaDisableVirtualCommand.php

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Algolia\AlgoliaSearch\Helper\Entity\ProductHelper;
1111
use Algolia\AlgoliaSearch\Service\StoreNameFetcher;
1212
use Magento\Framework\App\Cache\Manager as CacheManager;
13+
use Magento\Framework\App\Config\ReinitableConfigInterface;
1314
use Magento\Framework\App\Config\ScopeConfigInterface;
1415
use Magento\Framework\App\Config\Storage\WriterInterface;
1516
use Magento\Framework\App\State;
@@ -24,18 +25,18 @@ class ReplicaDisableVirtualCommand extends AbstractReplicaCommand implements Rep
2425
use ReplicaSyncCommandTrait;
2526

2627
public function __construct(
27-
protected WriterInterface $configWriter,
28-
protected ConfigChecker $configChecker,
29-
protected ScopeConfigInterface $scopeConfig,
30-
protected SerializerInterface $serializer,
31-
protected ConfigHelper $configHelper,
32-
protected CacheManager $cacheManager,
33-
protected ReplicaManagerInterface $replicaManager,
34-
protected StoreManagerInterface $storeManager,
35-
protected ProductHelper $productHelper,
36-
State $state,
37-
StoreNameFetcher $storeNameFetcher,
38-
?string $name = null
28+
protected WriterInterface $configWriter,
29+
protected ConfigChecker $configChecker,
30+
protected ReinitableConfigInterface $scopeConfig,
31+
protected SerializerInterface $serializer,
32+
protected ConfigHelper $configHelper,
33+
protected CacheManager $cacheManager,
34+
protected ReplicaManagerInterface $replicaManager,
35+
protected StoreManagerInterface $storeManager,
36+
protected ProductHelper $productHelper,
37+
State $state,
38+
StoreNameFetcher $storeNameFetcher,
39+
?string $name = null
3940
)
4041
{
4142
parent::__construct($state, $storeNameFetcher, $name);
@@ -95,7 +96,7 @@ protected function disableVirtualReplicas(array $storeIds = []): void
9596
}
9697
}
9798
if ($updates) {
98-
$this->clearCache();
99+
$this->scopeConfig->reinit();
99100
foreach ($updates as $storeId) {
100101
$this->syncReplicasForStore($storeId);
101102
}
@@ -142,7 +143,7 @@ protected function disableVirtualReplicasForAllStores(): void
142143

143144
$this->configChecker->checkAndApplyAllScopes(ConfigHelper::SORTING_INDICES, [$this, 'disableVirtualReplicaSortConfig']);
144145

145-
$this->clearCache();
146+
$this->scopeConfig->reinit();
146147

147148
$this->syncReplicasForAllStores();
148149
}
@@ -174,9 +175,4 @@ function($sort) {
174175
$this->configHelper->setSorting($sorting, $scope, $scopeId);
175176
}
176177

177-
protected function clearCache(): void
178-
{
179-
$this->cacheManager->clean(['config']);
180-
}
181-
182178
}

0 commit comments

Comments
 (0)