@infrab4a/connect-angular 4.1.4-beta.3 → 4.1.4-beta.5
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.
- package/esm2020/services/catalog/catalog.service.mjs +12 -8
- package/fesm2015/infrab4a-connect-angular.mjs +11 -7
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +11 -7
- package/fesm2020/infrab4a-connect-angular.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1538,6 +1538,7 @@ class CatalogService {
|
|
|
1538
1538
|
}
|
|
1539
1539
|
async findCatalogByTermAndSortByMostRevelant(options, limits) {
|
|
1540
1540
|
const productIds = await this.findCatalogIdsByElasticSearch(options.term);
|
|
1541
|
+
console.log(productIds);
|
|
1541
1542
|
const limitedProductId = productIds.slice(limits.offset, limits.limit);
|
|
1542
1543
|
const productResult = await this.productRepository.findCatalog({
|
|
1543
1544
|
filters: { id: { operator: Where.IN, value: limitedProductId } },
|
|
@@ -1561,13 +1562,16 @@ class CatalogService {
|
|
|
1561
1562
|
};
|
|
1562
1563
|
}
|
|
1563
1564
|
async findCatalogIdsByElasticSearch(term) {
|
|
1564
|
-
|
|
1565
|
-
this.
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
}));
|
|
1565
|
+
if (this.productsByTerm[term])
|
|
1566
|
+
return this.productsByTerm[term];
|
|
1567
|
+
return (this.productsByTerm[term] = await this.productIndex
|
|
1568
|
+
.search(term, 999, this.shop)
|
|
1569
|
+
.then(({ hits: products }) => {
|
|
1570
|
+
const withStock = products.filter(({ _source }) => _source.stock.quantity > 0);
|
|
1571
|
+
const withOutStock = products.filter(({ _source }) => _source.stock.quantity <= 0);
|
|
1572
|
+
const sorted = [...withStock, ...withOutStock];
|
|
1573
|
+
return [...new Set(sorted.map(({ _source }) => _source.id))];
|
|
1574
|
+
}));
|
|
1571
1575
|
}
|
|
1572
1576
|
}
|
|
1573
1577
|
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 });
|