@infrab4a/connect-angular 4.5.3-beta.9 → 4.5.4-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.
- package/esm2020/services/catalog/catalog.service.mjs +5 -33
- package/fesm2015/infrab4a-connect-angular.mjs +4 -35
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +4 -32
- package/fesm2020/infrab4a-connect-angular.mjs.map +1 -1
- package/package.json +2 -2
- package/services/catalog/catalog.service.d.ts +0 -1
|
@@ -1733,19 +1733,18 @@ class CatalogService {
|
|
|
1733
1733
|
async findCatalog(options, limits) {
|
|
1734
1734
|
if (this.hasTerm(options) && options.sort === 'most-relevant') {
|
|
1735
1735
|
const productsIds = await this.findCatalogIdsByElasticSearch(options.term);
|
|
1736
|
-
return this.
|
|
1736
|
+
return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
|
|
1737
1737
|
}
|
|
1738
1738
|
if (this.hasCategory(options) && options.sort === 'most-relevant') {
|
|
1739
|
-
const mostRelevant = options.category.mostRelevant ?? [];
|
|
1740
|
-
console.log('mostRelevant', mostRelevant);
|
|
1741
1739
|
const productsIds = await this.productRepository
|
|
1742
1740
|
.find({
|
|
1741
|
+
fields: ['id'],
|
|
1743
1742
|
filters: {
|
|
1744
1743
|
...(await this.buildMainFilter(options)),
|
|
1745
1744
|
},
|
|
1746
1745
|
})
|
|
1747
1746
|
.then((products) => products.data.map((product) => product.id));
|
|
1748
|
-
return this.findCatalogAndSortByMostRevelant(
|
|
1747
|
+
return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
|
|
1749
1748
|
}
|
|
1750
1749
|
const repoParams = {
|
|
1751
1750
|
filters: {
|
|
@@ -1774,34 +1773,7 @@ class CatalogService {
|
|
|
1774
1773
|
.search(term, 999, this.shop)
|
|
1775
1774
|
.then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
|
|
1776
1775
|
}
|
|
1777
|
-
async findCatalogAndSortByMostRevelant(
|
|
1778
|
-
console.log('mostRelevant', mostRelevants);
|
|
1779
|
-
console.log('productIds', productIds);
|
|
1780
|
-
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(productIds))];
|
|
1781
|
-
const totalResult = await this.productRepository.findCatalog({
|
|
1782
|
-
filters: {
|
|
1783
|
-
id: { operator: Where.IN, value: mostRelevantProductsIds },
|
|
1784
|
-
},
|
|
1785
|
-
orderBy: this.buildSortQuery('news'),
|
|
1786
|
-
options: {
|
|
1787
|
-
minimal: ['price'],
|
|
1788
|
-
maximum: ['price'],
|
|
1789
|
-
distinct: ['brand'],
|
|
1790
|
-
},
|
|
1791
|
-
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1792
|
-
const firstProducts = totalResult.data.filter((product) => mostRelevants.includes(product.id));
|
|
1793
|
-
const lastProducts = totalResult.data.filter((product) => !mostRelevants.includes(product.id));
|
|
1794
|
-
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
1795
|
-
const resultFinal = categoryMostRelevants.slice(limits.offset, limits.offset + limits.limit);
|
|
1796
|
-
return {
|
|
1797
|
-
data: resultFinal,
|
|
1798
|
-
count: totalResult.count,
|
|
1799
|
-
maximum: totalResult.maximum,
|
|
1800
|
-
minimal: totalResult.minimal,
|
|
1801
|
-
distinct: totalResult.distinct,
|
|
1802
|
-
};
|
|
1803
|
-
}
|
|
1804
|
-
async findCatalogAndSortByMostRevelantByTerm(productIds, options, limits) {
|
|
1776
|
+
async findCatalogAndSortByMostRevelant(productIds, options, limits) {
|
|
1805
1777
|
const totalResult = await this.productRepository.findCatalog({
|
|
1806
1778
|
fields: ['id', 'stock'],
|
|
1807
1779
|
filters: {
|