Skip to content

Commit 2e2b41b

Browse files
committed
Added option to select replica type per attribute
1 parent c3f315e commit 2e2b41b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Helper/ConfigHelper.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ class ConfigHelper
134134
public const ENHANCED_QUEUE_ARCHIVE = 'algoliasearch_advanced/queue/enhanced_archive';
135135
public const NUMBER_OF_ELEMENT_BY_PAGE = 'algoliasearch_advanced/queue/number_of_element_by_page';
136136
public const ARCHIVE_LOG_CLEAR_LIMIT = 'algoliasearch_advanced/queue/archive_clear_limit';
137+
public const MAX_VIRTUAL_REPLICA_COUNT = 50;
137138

138139
/**
139140
* @var Magento\Framework\App\Config\ScopeConfigInterface
@@ -993,8 +994,9 @@ public function getSortingIndices($originalIndexName, $storeId = null, $currentC
993994
$currency = $this->getCurrencyCode($storeId);
994995
$attributesToAdd = [];
995996
$defaultVirtualReplicaEnabled = $this->useVirtualReplica($storeId);
997+
$virtualReplicaCount = 0;
996998
foreach ($attrs as $key => $attr) {
997-
if ($defaultVirtualReplicaEnabled || (isset($attr['virtualReplica']) && $attr['virtualReplica'])){
999+
if ($virtualReplicaCount < self::MAX_VIRTUAL_REPLICA_COUNT && ($defaultVirtualReplicaEnabled || (isset($attr['virtualReplica']) && $attr['virtualReplica']))){
9981000
$virtualReplica = 1;
9991001
} else {
10001002
$virtualReplica = 0;
@@ -1033,6 +1035,7 @@ public function getSortingIndices($originalIndexName, $storeId = null, $currentC
10331035
'custom',
10341036
];
10351037
$attributesToAdd[$newAttr['sort']][] = $newAttr;
1038+
$virtualReplicaCount++;
10361039
}
10371040
} elseif ($attr['attribute'] === 'price') {
10381041
$indexName = $originalIndexName . '_' . $attr['attribute'] . '_' . 'default' . '_' . $attr['sort'];
@@ -1058,6 +1061,7 @@ public function getSortingIndices($originalIndexName, $storeId = null, $currentC
10581061
'exact',
10591062
'custom',
10601063
];
1064+
$virtualReplicaCount++;
10611065
}
10621066
}
10631067
$attrsToReturn = [];

0 commit comments

Comments
 (0)