@infrab4a/connect-angular 4.2.1-beta.1 → 4.2.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1588,20 +1588,27 @@ class CatalogService {
1588
1588
  }
1589
1589
  async findCatalogByTermAndSortByMostRevelant(options, limits) {
1590
1590
  const productIds = await this.findCatalogIdsByElasticSearch(options.term);
1591
- const limitedProductId = productIds.slice(limits.offset, limits.offset + limits.limit);
1592
- const productResult = await this.productRepository.findCatalog({
1593
- filters: { id: { operator: Where.IN, value: limitedProductId } },
1594
- }, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
1595
1591
  const totalResult = await this.productRepository.findCatalog({
1596
1592
  fields: ['id'],
1597
- filters: { id: { operator: Where.IN, value: productIds } },
1598
- limits: { limit: 1, offset: 0 },
1593
+ filters: {
1594
+ id: { operator: Where.IN, value: productIds },
1595
+ ...this.buildFilterQuery(options?.filters || {}),
1596
+ },
1599
1597
  options: {
1600
1598
  minimal: ['price'],
1601
1599
  maximum: ['price'],
1602
1600
  distinct: ['brand'],
1603
1601
  },
1604
1602
  }, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
1603
+ const limitedProductId = totalResult.data
1604
+ .slice(limits.offset, limits.offset + limits.limit)
1605
+ .map((product) => product.id);
1606
+ const orderedId = productIds.filter((product) => limitedProductId.includes(product));
1607
+ const productResult = await this.productRepository.findCatalog({
1608
+ filters: {
1609
+ id: { operator: Where.IN, value: orderedId },
1610
+ },
1611
+ });
1605
1612
  return {
1606
1613
  data: limitedProductId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean),
1607
1614
  count: totalResult.count,