@@ -464,7 +464,7 @@ public function setSettings($indexName, $indexNameTmp, $storeId, $saveToTmpIndic
464
464
465
465
if ($ this ->configHelper ->isInstantEnabled ($ storeId )) {
466
466
$ replicas = array_values (array_map (function ($ sortingIndex ) {
467
- return [ $ sortingIndex ['name ' ], $ sortingIndex [ ' virtualReplica ' ] ];
467
+ return $ sortingIndex ['name ' ];
468
468
}, $ sortingIndices ));
469
469
}
470
470
@@ -488,23 +488,24 @@ public function setSettings($indexName, $indexNameTmp, $storeId, $saveToTmpIndic
488
488
$ this ->logger ->log ('Setting replicas to " ' . $ indexName . '" index. ' );
489
489
$ this ->logger ->log ('Replicas: ' . json_encode ($ replicas ));
490
490
$ setReplicasTaskId = $ this ->algoliaHelper ->getLastTaskId ();
491
- foreach ($ sortingIndices as $ values ) {
492
- if ($ values ['virtualReplica ' ]) {
491
+ if (!$ this ->configHelper ->useVirtualReplica ($ storeId )) {
492
+ foreach ($ sortingIndices as $ values ) {
493
+ $ replicaName = $ values ['name ' ];
494
+ $ indexSettings ['ranking ' ] = $ values ['ranking ' ];
495
+ $ this ->algoliaHelper ->setSettings ($ replicaName , $ indexSettings , false , true );
496
+ $ this ->logger ->log ('Setting settings to " ' . $ replicaName . '" replica. ' );
497
+ $ this ->logger ->log ('Settings: ' . json_encode ($ indexSettings ));
498
+ }
499
+ } else {
500
+ foreach ($ sortingIndices as $ values ) {
493
501
$ replicaName = $ values ['name ' ];
494
502
array_unshift ($ customRanking , $ values ['ranking ' ][0 ]);
495
503
$ replicaSetting ['customRanking ' ] = $ customRanking ;
496
504
$ this ->algoliaHelper ->setSettings ($ replicaName , $ replicaSetting , false , false );
497
505
$ this ->logger ->log ('Setting settings to " ' . $ replicaName . '" replica. ' );
498
506
$ this ->logger ->log ('Settings: ' . json_encode ($ replicaSetting ));
499
- } else {
500
- $ replicaName = $ values ['name ' ];
501
- $ indexSettings ['ranking ' ] = $ values ['ranking ' ];
502
- $ this ->algoliaHelper ->setSettings ($ replicaName , $ indexSettings , false , true );
503
- $ this ->logger ->log ('Setting settings to " ' . $ replicaName . '" replica. ' );
504
- $ this ->logger ->log ('Settings: ' . json_encode ($ indexSettings ));
505
507
}
506
508
}
507
-
508
509
} else {
509
510
$ this ->algoliaHelper ->setSettings ($ indexName , ['replicas ' => []]);
510
511
$ this ->logger ->log ('Removing replicas from " ' . $ indexName . '" index ' );
@@ -1546,13 +1547,9 @@ public function handleVirtualReplica($replicas)
1546
1547
{
1547
1548
$ virtualReplicaArray = [];
1548
1549
foreach ($ replicas as $ replica ) {
1549
- if ($ replica [1 ]) {
1550
- $ replicaArray [] = 'virtual( ' . $ replica [0 ] . ') ' ;
1551
- } else {
1552
- $ replicaArray [] = $ replica [0 ];
1553
- }
1550
+ $ virtualReplicaArray [] = 'virtual( ' . $ replica . ') ' ;
1554
1551
}
1555
- return $ replicaArray ;
1552
+ return $ virtualReplicaArray ;
1556
1553
}
1557
1554
1558
1555
/**
@@ -1567,7 +1564,7 @@ public function handlingReplica($indexName, $storeId, $sortingAttribute = false)
1567
1564
$ sortingIndices = $ this ->configHelper ->getSortingIndices ($ indexName , $ storeId , null , $ sortingAttribute );
1568
1565
if ($ this ->configHelper ->isInstantEnabled ($ storeId )) {
1569
1566
$ replicas = array_values (array_map (function ($ sortingIndex ) {
1570
- return [ $ sortingIndex ['name ' ], $ sortingIndex [ ' virtualReplica ' ] ];
1567
+ return $ sortingIndex ['name ' ];
1571
1568
}, $ sortingIndices ));
1572
1569
1573
1570
try {
0 commit comments