Skip to content

Commit 42d0637

Browse files
committed
Merge branch 'ACP2E-2279' of https://github.com/magento-l3/magento2ce into PR-VK-2023-09-29
2 parents 75dcfb0 + d5688dd commit 42d0637

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/StaticField.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ public function getField(AbstractAttribute $attribute): array
164164
),
165165
'index' => $this->indexTypeConverter->convert(
166166
IndexTypeConverterInterface::INTERNAL_NO_ANALYZE_VALUE
167-
)
167+
),
168+
'normalizer' => 'folding',
168169
];
169170
}
170171

@@ -202,7 +203,8 @@ public function getField(AbstractAttribute $attribute): array
202203
),
203204
'index' => $this->indexTypeConverter->convert(
204205
IndexTypeConverterInterface::INTERNAL_NO_ANALYZE_VALUE
205-
)
206+
),
207+
'normalizer' => 'folding',
206208
];
207209
}
208210
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ public function build()
105105
'tokenizer' => $tokenizer,
106106
'filter' => array_merge($filter, $synonymFilter),
107107
'char_filter' => $charFilter,
108+
'normalizer' => [
109+
'folding' => [
110+
'type' => 'custom',
111+
'filter' => ['asciifolding', 'lowercase'],
112+
],
113+
],
108114
],
109115
];
110116

app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/StaticFieldTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ public function attributeProvider(): array
297297
'sort_attr_code' => [
298298
'type' => 'string',
299299
'index' => 'not_analyzed',
300+
'normalizer' => 'folding',
300301
],
301302
],
302303
],
@@ -375,6 +376,7 @@ public function attributeProvider(): array
375376
'sort_attr_code' => [
376377
'type' => 'string',
377378
'index' => 'not_analyzed',
379+
'normalizer' => 'folding',
378380
],
379381
],
380382
],

dev/tests/integration/testsuite/Magento/Elasticsearch/Model/Indexer/ReindexAllTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
namespace Magento\Elasticsearch\Model\Indexer;
77

88
use Magento\Catalog\Api\ProductRepositoryInterface;
9+
use Magento\Catalog\Test\Fixture\Product as ProductFixture;
910
use Magento\Indexer\Model\Indexer;
11+
use Magento\TestFramework\Fixture\DataFixture;
1012
use Magento\TestFramework\Helper\Bootstrap;
1113
use Magento\Store\Model\StoreManagerInterface;
1214
use Magento\Elasticsearch\SearchAdapter\ConnectionManager;
@@ -75,6 +77,7 @@ protected function assertPreConditions(): void
7577
{
7678
$objectManager = Bootstrap::getObjectManager();
7779
$currentEngine = $objectManager->get(EngineResolverInterface::class)->getCurrentSearchEngine();
80+
// phpstan:ignore "Class Magento\TestModuleCatalogSearch\Model\SearchEngineVersionReader not found."
7881
$installedEngine = $objectManager->get(SearchEngineVersionReader::class)->getFullVersion();
7982
$this->assertEquals(
8083
$installedEngine,
@@ -166,6 +169,29 @@ public function testSortCaseSensitive(): void
166169
self::assertEquals($productThird->getId(), $fifthInSearchResults);
167170
}
168171

172+
#[
173+
DataFixture(ProductFixture::class, ['sku' => 'p1', 'name' => 'A']),
174+
DataFixture(ProductFixture::class, ['sku' => 'p2', 'name' => 'Ç']),
175+
DataFixture(ProductFixture::class, ['sku' => 'p3', 'name' => 'D']),
176+
DataFixture(ProductFixture::class, ['sku' => 'p4', 'name' => 'Ü']),
177+
DataFixture(ProductFixture::class, ['sku' => 'p5', 'name' => 'Z']),
178+
]
179+
public function testSortAccentedCharacters(): void
180+
{
181+
$expectedOrder = [
182+
(int) $this->productRepository->get('p1')->getId(),
183+
(int) $this->productRepository->get('p2')->getId(),
184+
(int) $this->productRepository->get('p3')->getId(),
185+
(int) $this->productRepository->get('p4')->getId(),
186+
(int) $this->productRepository->get('p5')->getId(),
187+
];
188+
$this->reindexAll();
189+
190+
$result = $this->sortByName();
191+
$actualOrder = array_map(fn ($id) => (int) $id, array_column($result, '_id'));
192+
self::assertEquals($expectedOrder, $actualOrder);
193+
}
194+
169195
/**
170196
* Test search of specific product after full reindex
171197
*

0 commit comments

Comments
 (0)