diff --git a/packages/core/e2e/default-search-plugin.e2e-spec.ts b/packages/core/e2e/default-search-plugin.e2e-spec.ts index 033d43963c..247bf7ab02 100644 --- a/packages/core/e2e/default-search-plugin.e2e-spec.ts +++ b/packages/core/e2e/default-search-plugin.e2e-spec.ts @@ -1849,6 +1849,7 @@ describe('Default search plugin', () => { 'Instant Camera', 'Laptop en', // fallback language en 'Orchid', + 'product en', // fallback language en 'Road Bike', 'Running Shoe', 'Skipping Rope', @@ -1858,7 +1859,6 @@ describe('Default search plugin', () => { 'Tent', 'Tripod', 'USB Cable', - 'product en', // fallback language en ]; expect(search.items.map(i => i.productName)).toEqual(productNames); @@ -1878,6 +1878,7 @@ describe('Default search plugin', () => { 'Instant Camera', 'Laptop de', // language de 'Orchid', + 'product de', // language de 'Road Bike', 'Running Shoe', 'Skipping Rope', @@ -1887,7 +1888,6 @@ describe('Default search plugin', () => { 'Tent', 'Tripod', 'USB Cable', - 'product de', // language de ]; expect(search.items.map(i => i.productName)).toEqual(productNames); @@ -1907,6 +1907,7 @@ describe('Default search plugin', () => { 'Instant Camera', 'Laptop zh', // language zh 'Orchid', + 'product en', // fallback language en 'Road Bike', 'Running Shoe', 'Skipping Rope', @@ -1916,7 +1917,6 @@ describe('Default search plugin', () => { 'Tent', 'Tripod', 'USB Cable', - 'product en', // fallback language en ]; expect(search.items.map(i => i.productName)).toEqual(productNames); diff --git a/packages/core/src/plugin/default-search-plugin/search-strategy/mysql-search-strategy.ts b/packages/core/src/plugin/default-search-plugin/search-strategy/mysql-search-strategy.ts index 5c1c7a722e..b560a926c8 100644 --- a/packages/core/src/plugin/default-search-plugin/search-strategy/mysql-search-strategy.ts +++ b/packages/core/src/plugin/default-search-plugin/search-strategy/mysql-search-strategy.ts @@ -251,6 +251,7 @@ export class MysqlSearchStrategy implements SearchStrategy { applyLanguageConstraints(qb, ctx.languageCode, ctx.channel.defaultLanguageCode); qb.andWhere('si.channelId = :channelId', { channelId: ctx.channelId }); + if (input.groupByProduct === true) { qb.groupBy('si.productId'); qb.addSelect('BIT_OR(si.enabled)', 'productEnabled'); diff --git a/packages/core/src/plugin/default-search-plugin/search-strategy/postgres-search-strategy.ts b/packages/core/src/plugin/default-search-plugin/search-strategy/postgres-search-strategy.ts index 2bfc99d28b..f156d087b0 100644 --- a/packages/core/src/plugin/default-search-plugin/search-strategy/postgres-search-strategy.ts +++ b/packages/core/src/plugin/default-search-plugin/search-strategy/postgres-search-strategy.ts @@ -249,9 +249,11 @@ export class PostgresSearchStrategy implements SearchStrategy { applyLanguageConstraints(qb, ctx.languageCode, ctx.channel.defaultLanguageCode); qb.andWhere('si.channelId = :channelId', { channelId: ctx.channelId }); + if (input.groupByProduct === true) { qb.groupBy('si.productId'); } + return qb; } diff --git a/packages/core/src/plugin/default-search-plugin/search-strategy/sqlite-search-strategy.ts b/packages/core/src/plugin/default-search-plugin/search-strategy/sqlite-search-strategy.ts index 1b3c7782f8..d3cbd4c037 100644 --- a/packages/core/src/plugin/default-search-plugin/search-strategy/sqlite-search-strategy.ts +++ b/packages/core/src/plugin/default-search-plugin/search-strategy/sqlite-search-strategy.ts @@ -99,7 +99,8 @@ export class SqliteSearchStrategy implements SearchStrategy { } if (sort) { if (sort.name) { - qb.addOrderBy('si.productName', sort.name); + // TODO: v3 - set the collation on the SearchIndexItem entity + qb.addOrderBy('si.productName COLLATE NOCASE', sort.name); } if (sort.price) { qb.addOrderBy('si.price', sort.price);