Skip to content

Commit 4967683

Browse files
committed
MAGE-840 Update code comments
1 parent ed2307c commit 4967683

File tree

1 file changed

+1
-22
lines changed

1 file changed

+1
-22
lines changed

Model/Product/ReplicaManager.php

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,6 @@ public function __construct(
5555
* @throws LocalizedException
5656
*/
5757
protected function hasReplicaConfigurationChanged(string $indexName, int $storeId): bool {
58-
/*
59-
* Method 1 (exhaustive)
60-
* Get the current replica configuration from Algolia
61-
* Extract the non Magento replicas (e.g. sorting strategies, dashboard managed, etc.)
62-
* Calculate the new replica setting for Magento
63-
* Merge the non Magento replicas with new Magento replica config
64-
* Perform an array diff (this code can be optimized based on how array_diff works)
65-
* If there is a change return true else return false
66-
*
67-
* Method 2 (efficient)
68-
* Get the current replica configuration from Algolia
69-
* Remove non Magento replicas from list and call this $old
70-
* Determine new Magento replica config and call this $new
71-
* Sort both arrays ($old and $new)
72-
* Compare the arrays (array diff etc) and return true if not matching (order should not matter)
73-
*
74-
* This gets complicated however if we are dealing with stores -
75-
* so we must abstract the obtaining of the replica configuration from Algolia
76-
* In other words if a store is using the default config we compare the sorts to the default index
77-
* If however there is store scoping - we must isolate the store specific index and compare to that
78-
*/
79-
8058
$old = $this->getMagentoReplicaConfigurationFromAlgolia($indexName, $storeId);
8159
$new = $this->transformSortingIndicesToReplicaSetting($this->configHelper->getSortingIndices($indexName, $storeId));
8260
sort($old);
@@ -220,6 +198,7 @@ protected function setReplicasOnPrimaryIndex($indexName, int $storeId): array
220198
$oldMagentoReplicaIndices = $this->getBareIndexNamesFromReplicaSetting($oldMagentoReplicas);
221199
$newMagentoReplicaIndices = $this->getBareIndexNamesFromReplicaSetting($newMagentoReplicas);
222200
$replicasToDelete = array_diff($oldMagentoReplicaIndices, $newMagentoReplicaIndices);
201+
// TODO: Refactor for virtual / standard toggle - not just added replica indices require ranking config
223202
$replicasToAdd = array_diff($newMagentoReplicaIndices, $oldMagentoReplicaIndices);
224203
$this->algoliaHelper->setSettings($indexName, ['replicas' => array_merge($newMagentoReplicas, $nonMagentoReplicas)]);
225204
$setReplicasTaskId = $this->algoliaHelper->getLastTaskId();

0 commit comments

Comments
 (0)