@@ -55,28 +55,6 @@ public function __construct(
55
55
* @throws LocalizedException
56
56
*/
57
57
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
-
80
58
$ old = $ this ->getMagentoReplicaConfigurationFromAlgolia ($ indexName , $ storeId );
81
59
$ new = $ this ->transformSortingIndicesToReplicaSetting ($ this ->configHelper ->getSortingIndices ($ indexName , $ storeId ));
82
60
sort ($ old );
@@ -220,6 +198,7 @@ protected function setReplicasOnPrimaryIndex($indexName, int $storeId): array
220
198
$ oldMagentoReplicaIndices = $ this ->getBareIndexNamesFromReplicaSetting ($ oldMagentoReplicas );
221
199
$ newMagentoReplicaIndices = $ this ->getBareIndexNamesFromReplicaSetting ($ newMagentoReplicas );
222
200
$ replicasToDelete = array_diff ($ oldMagentoReplicaIndices , $ newMagentoReplicaIndices );
201
+ // TODO: Refactor for virtual / standard toggle - not just added replica indices require ranking config
223
202
$ replicasToAdd = array_diff ($ newMagentoReplicaIndices , $ oldMagentoReplicaIndices );
224
203
$ this ->algoliaHelper ->setSettings ($ indexName , ['replicas ' => array_merge ($ newMagentoReplicas , $ nonMagentoReplicas )]);
225
204
$ setReplicasTaskId = $ this ->algoliaHelper ->getLastTaskId ();
0 commit comments