Skip to content

Commit fec41fe

Browse files
committed
MC-31304: [ElasticSearch] Exception on catalog search result page
1 parent b9dec6e commit fec41fe

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

app/code/Magento/Elasticsearch/Model/Adapter/Elasticsearch.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ public function updateIndexMapping(int $storeId, string $mappedIndexerId): self
380380
$indexName,
381381
$this->clientConfig->getEntityType()
382382
);
383-
$this->setMappedAttributes($attrToUpdate);
383+
$this->setMappedAttributes($indexName, $attrToUpdate);
384384
}
385385

386386
return $this;
@@ -395,7 +395,7 @@ public function updateIndexMapping(int $storeId, string $mappedIndexerId): self
395395
*/
396396
private function getIndexFromAlias(int $storeId, string $mappedIndexerId): string
397397
{
398-
$indexCode = $mappedIndexerId . $storeId;
398+
$indexCode = $mappedIndexerId . '_' . $storeId;
399399
if (!isset($this->indexByCode[$indexCode])) {
400400
$this->indexByCode[$indexCode] = $this->indexNameResolver->getIndexFromAlias($storeId, $mappedIndexerId);
401401
}
@@ -411,25 +411,26 @@ private function getIndexFromAlias(int $storeId, string $mappedIndexerId): strin
411411
*/
412412
private function getMappedAttributes(string $indexName): array
413413
{
414-
if (empty($this->mappedAttributes)) {
414+
if (empty($this->mappedAttributes[$indexName])) {
415415
$mappedAttributes = $this->client->getMapping(['index' => $indexName]);
416416
$pathField = $this->arrayManager->findPath('properties', $mappedAttributes);
417-
$this->mappedAttributes = $this->arrayManager->get($pathField, $mappedAttributes, []);
417+
$this->mappedAttributes[$indexName] = $this->arrayManager->get($pathField, $mappedAttributes, []);
418418
}
419419

420-
return $this->mappedAttributes;
420+
return $this->mappedAttributes[$indexName];
421421
}
422422

423423
/**
424424
* Set mapped attributes to cache.
425425
*
426+
* @param string $indexName
426427
* @param array $mappedAttributes
427428
* @return $this
428429
*/
429-
private function setMappedAttributes(array $mappedAttributes): self
430+
private function setMappedAttributes(string $indexName, array $mappedAttributes): self
430431
{
431432
foreach ($mappedAttributes as $attributeCode => $attributeParams) {
432-
$this->mappedAttributes[$attributeCode] = $attributeParams;
433+
$this->mappedAttributes[$indexName][$attributeCode] = $attributeParams;
433434
}
434435

435436
return $this;

0 commit comments

Comments
 (0)