Skip to content

Commit 56bd4dc

Browse files
authored
Merge pull request #1625 from algolia/bugfix/MAGE-1081-stale-replica-setting-comparison
MAGE-1081 Pull fresh settings data if Algolia state changes over life…
2 parents 6564ef3 + f5fb91b commit 56bd4dc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Service/Product/ReplicaManager.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,14 @@ protected function clearAlgoliaReplicaSettingCache($primaryIndexName = null): vo
133133
* relevant to the Magento integration
134134
*
135135
* @param string $primaryIndexName
136+
* @param bool $refreshCache
136137
* @return string[] Array of replica index names
137138
* @throws LocalizedException
139+
* @throws NoSuchEntityException
138140
*/
139-
protected function getMagentoReplicaConfigurationFromAlgolia(string $primaryIndexName): array
141+
protected function getMagentoReplicaConfigurationFromAlgolia(string $primaryIndexName, bool $refreshCache = false): array
140142
{
141-
$algoliaReplicas = $this->getReplicaConfigurationFromAlgolia($primaryIndexName);
143+
$algoliaReplicas = $this->getReplicaConfigurationFromAlgolia($primaryIndexName, $refreshCache);
142144
$magentoReplicas = $this->getMagentoReplicaSettings($primaryIndexName, $algoliaReplicas);
143145
return array_values(array_intersect($magentoReplicas, $algoliaReplicas));
144146
}
@@ -241,7 +243,7 @@ protected function setReplicasOnPrimaryIndex(int $storeId): array
241243
$indexName = $this->indexNameFetcher->getProductIndexName($storeId);
242244
$sortingIndices = $this->sortingTransformer->getSortingIndices($storeId);
243245
$newMagentoReplicasSetting = $this->sortingTransformer->transformSortingIndicesToReplicaSetting($sortingIndices);
244-
$oldMagentoReplicasSetting = $this->getMagentoReplicaConfigurationFromAlgolia($indexName);
246+
$oldMagentoReplicasSetting = $this->getMagentoReplicaConfigurationFromAlgolia($indexName, true);
245247
$nonMagentoReplicasSetting = $this->getNonMagentoReplicaConfigurationFromAlgolia($indexName);
246248
$oldMagentoReplicaIndices = $this->getBareIndexNamesFromReplicaSetting($oldMagentoReplicasSetting);
247249
$newMagentoReplicaIndices = $this->getBareIndexNamesFromReplicaSetting($newMagentoReplicasSetting);

0 commit comments

Comments
 (0)