Skip to content

Commit

Permalink
refactor(core): Use template string and getOne in ProductService
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Apr 2, 2021
1 parent 7d26c09 commit ec59bda
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions packages/core/src/service/services/product.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,12 @@ export class ProductService {
.andWhere('product.deletedAt IS NULL')
.andWhere('channel.id = :channelId', { channelId: ctx.channelId })
.addSelect(
'CASE product_translations.languageCode WHEN \'' +
ctx.languageCode +
'\' THEN 2 WHEN \'' +
ctx.channel.defaultLanguageCode +
'\' THEN 1 ELSE 0 END',
`CASE product_translations.languageCode WHEN '${ctx.languageCode}' THEN 2 WHEN '${ctx.channel.defaultLanguageCode}' THEN 1 ELSE 0 END`,
'sort_order',
)
.orderBy('sort_order', 'DESC')
.limit(1)
.getMany()
.then(products => products[0])
.getOne()
.then(product =>
product
? translateDeep(product, ctx.languageCode, ['facetValues', ['facetValues', 'facet']])
Expand Down

0 comments on commit ec59bda

Please sign in to comment.