@infrab4a/connect-angular 4.1.4-beta.2 → 4.1.4-beta.3

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.
@@ -1562,9 +1562,12 @@ class CatalogService {
1562
1562
  }
1563
1563
  async findCatalogIdsByElasticSearch(term) {
1564
1564
  return (this.productsByTerm[term] ||
1565
- this.productIndex
1566
- .search(term, 999, this.shop)
1567
- .then((data) => [...new Set(data.hits.map(({ _source }) => _source.id))]));
1565
+ this.productIndex.search(term, 999, this.shop).then(({ hits: products }) => {
1566
+ const withStock = products.filter(({ _source }) => _source.stock.quantity > 0);
1567
+ const withOutStock = products.filter(({ _source }) => _source.stock.quantity <= 0);
1568
+ const sorted = [...withStock, ...withOutStock];
1569
+ return [...new Set(sorted.map(({ _source }) => _source.id))];
1570
+ }));
1568
1571
  }
1569
1572
  }
1570
1573
  CatalogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable });