@@ -463,7 +463,7 @@ public function setSettings($indexName, $indexNameTmp, $storeId, $saveToTmpIndic
463
463
464
464
// Managing Virtual Replica
465
465
if ($ this ->configHelper ->useVirtualReplica ($ storeId )) {
466
- $ replicas = $ this ->handleVirtualReplica ($ replicas );
466
+ $ replicas = $ this ->handleVirtualReplica ($ replicas, $ indexName );
467
467
}
468
468
469
469
// Merge current replicas with sorting replicas to not delete A/B testing replica indices
@@ -1534,7 +1534,7 @@ public function productIsInStock($product, $storeId)
1534
1534
* @param $replica
1535
1535
* @return array
1536
1536
*/
1537
- public function handleVirtualReplica ($ replicas )
1537
+ public function handleVirtualReplica ($ replicas, $ indexName )
1538
1538
{
1539
1539
$ virtualReplicaArray = [];
1540
1540
foreach ($ replicas as $ replica ) {
@@ -1558,14 +1558,12 @@ public function handlingReplica($indexName, $storeId, $sortingAttribute = false)
1558
1558
return $ sortingIndex ['name ' ];
1559
1559
}, $ sortingIndices ));
1560
1560
try {
1561
- $ replicasFormated = $ this ->handleVirtualReplica ($ replicas );
1562
- $ availableReplicaMatch = array_merge ($ replicasFormated , $ replicas );
1563
1561
if ($ this ->configHelper ->useVirtualReplica ($ storeId )) {
1564
- $ replicas = $ replicasFormated ;
1562
+ $ replicas = $ this -> handleVirtualReplica ( $ replicas , $ indexName ) ;
1565
1563
}
1566
1564
$ currentSettings = $ this ->algoliaHelper ->getSettings ($ indexName );
1567
1565
if (is_array ($ currentSettings ) && array_key_exists ('replicas ' , $ currentSettings )) {
1568
- $ replicasRequired = array_values (array_diff ($ currentSettings ['replicas ' ], $ availableReplicaMatch ));
1566
+ $ replicasRequired = array_values (array_diff_assoc ($ currentSettings ['replicas ' ], $ replicas ));
1569
1567
$ this ->algoliaHelper ->setSettings ($ indexName , ['replicas ' => $ replicasRequired ]);
1570
1568
$ setReplicasTaskId = $ this ->algoliaHelper ->getLastTaskId ();
1571
1569
$ this ->algoliaHelper ->waitLastTask ($ indexName , $ setReplicasTaskId );
0 commit comments