@infrab4a/connect-angular 4.5.3-beta.0 → 4.5.3-beta.10
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 -26
- package/fesm2015/infrab4a-connect-angular.mjs +15 -25
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +11 -25
- package/fesm2020/infrab4a-connect-angular.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -1736,10 +1736,11 @@ class CatalogService {
|
|
|
1736
1736
|
return this.findCatalogAndSortByMostRevelantByTerm(productsIds, options, limits);
|
|
1737
1737
|
}
|
|
1738
1738
|
if (this.hasCategory(options) && options.sort === 'most-relevant') {
|
|
1739
|
-
const
|
|
1739
|
+
const mostRelevant = options.category.mostRelevant ?? [];
|
|
1740
1740
|
console.log('mostRelevant', mostRelevant);
|
|
1741
1741
|
const productsIds = await this.productRepository
|
|
1742
1742
|
.find({
|
|
1743
|
+
fields: ['id'],
|
|
1743
1744
|
filters: {
|
|
1744
1745
|
...(await this.buildMainFilter(options)),
|
|
1745
1746
|
},
|
|
@@ -1775,41 +1776,26 @@ class CatalogService {
|
|
|
1775
1776
|
.then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
|
|
1776
1777
|
}
|
|
1777
1778
|
async findCatalogAndSortByMostRevelant(mostRelevants, productIds, options, limits) {
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
}
|
|
1782
|
-
if (offset > 0) {
|
|
1783
|
-
limits.offset -= mostRelevants.length;
|
|
1784
|
-
}
|
|
1785
|
-
const mostRelevantProductsIds = [...new Set(...mostRelevants, ...productIds)];
|
|
1779
|
+
console.log('mostRelevant', mostRelevants);
|
|
1780
|
+
console.log('productIds', productIds);
|
|
1781
|
+
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(productIds))];
|
|
1786
1782
|
const totalResult = await this.productRepository.findCatalog({
|
|
1787
|
-
fields: ['id', 'stock'],
|
|
1788
1783
|
filters: {
|
|
1789
1784
|
id: { operator: Where.IN, value: mostRelevantProductsIds },
|
|
1790
|
-
...this.buildFilterQuery(options?.filters || {}),
|
|
1791
1785
|
},
|
|
1786
|
+
orderBy: this.buildSortQuery('news'),
|
|
1792
1787
|
options: {
|
|
1793
1788
|
minimal: ['price'],
|
|
1794
1789
|
maximum: ['price'],
|
|
1795
1790
|
distinct: ['brand'],
|
|
1796
1791
|
},
|
|
1797
1792
|
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1798
|
-
const
|
|
1799
|
-
const
|
|
1800
|
-
const
|
|
1801
|
-
const
|
|
1802
|
-
const limitedProductId = productIdsStock
|
|
1803
|
-
.concat(productIdsStockOut)
|
|
1804
|
-
.slice(limits.offset, limits.offset + limits.limit);
|
|
1805
|
-
const orderedId = productIds.filter((product) => limitedProductId.includes(product));
|
|
1806
|
-
const productResult = await this.productRepository.findCatalog({
|
|
1807
|
-
filters: {
|
|
1808
|
-
id: { operator: Where.IN, value: orderedId },
|
|
1809
|
-
},
|
|
1810
|
-
});
|
|
1793
|
+
const firstProducts = totalResult.data.filter((product) => mostRelevants.includes(product.id));
|
|
1794
|
+
const lastProducts = totalResult.data.filter((product) => !mostRelevants.includes(product.id));
|
|
1795
|
+
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
1796
|
+
const resultFinal = categoryMostRelevants.slice(limits.offset, limits.offset + limits.limit);
|
|
1811
1797
|
return {
|
|
1812
|
-
data:
|
|
1798
|
+
data: resultFinal,
|
|
1813
1799
|
count: totalResult.count,
|
|
1814
1800
|
maximum: totalResult.maximum,
|
|
1815
1801
|
minimal: totalResult.minimal,
|