@infrab4a/connect-angular 5.2.2-beta.4 → 5.2.2-beta.6
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/adapters/new-category-structure.adapter.mjs +10 -1
- package/esm2020/services/catalog/adapters/old-category-structure.adapter.mjs +2 -1
- package/esm2020/services/catalog/catalog.service.mjs +2 -1
- package/esm2020/services/catalog/category.service.mjs +7 -2
- package/esm2020/services/catalog/strategies/category-search.strategy.mjs +17 -1
- package/fesm2015/infrab4a-connect-angular.mjs +24 -1
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +33 -1
- package/fesm2020/infrab4a-connect-angular.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -1385,9 +1385,18 @@ class NewCategoryStructureAdapter {
|
|
|
1385
1385
|
}
|
|
1386
1386
|
async buildProductFilterByCategory(category) {
|
|
1387
1387
|
const loadedCategory = await this.getCategory(category);
|
|
1388
|
+
console.warn('loadedCategory', loadedCategory);
|
|
1388
1389
|
if (loadedCategory.isCollection)
|
|
1389
1390
|
return { id: { operator: Where.IN, value: loadedCategory.products } };
|
|
1390
1391
|
const categoryIds = [...(await this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
|
|
1392
|
+
console.warn('new buildProductFilterByCategory', {
|
|
1393
|
+
category: {
|
|
1394
|
+
id: {
|
|
1395
|
+
operator: Where.IN,
|
|
1396
|
+
value: categoryIds,
|
|
1397
|
+
},
|
|
1398
|
+
},
|
|
1399
|
+
});
|
|
1391
1400
|
return {
|
|
1392
1401
|
category: {
|
|
1393
1402
|
id: {
|
|
@@ -1427,6 +1436,7 @@ class OldCategoryStructureAdapter {
|
|
|
1427
1436
|
const productsIds = category.products?.length
|
|
1428
1437
|
? category.products
|
|
1429
1438
|
: await this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
|
|
1439
|
+
console.warn('old OldCategoryStructureAdapter', { id: { operator: Where.IN, value: productsIds } });
|
|
1430
1440
|
return { id: { operator: Where.IN, value: productsIds } };
|
|
1431
1441
|
}
|
|
1432
1442
|
}
|
|
@@ -1501,6 +1511,7 @@ class CategorySearchStrategy {
|
|
|
1501
1511
|
fields,
|
|
1502
1512
|
});
|
|
1503
1513
|
}
|
|
1514
|
+
console.warn('default search', category);
|
|
1504
1515
|
return this.searchDefault({
|
|
1505
1516
|
category,
|
|
1506
1517
|
filters,
|
|
@@ -1513,6 +1524,7 @@ class CategorySearchStrategy {
|
|
|
1513
1524
|
});
|
|
1514
1525
|
}
|
|
1515
1526
|
async searchWithMostRelevant(params) {
|
|
1527
|
+
console.warn('searchWithMostRelevant', params);
|
|
1516
1528
|
const { category, filters, shop, optionsCache } = params;
|
|
1517
1529
|
const mostRelevant = category.isWishlist ? [] : category.getMostRelevantByShop(shop);
|
|
1518
1530
|
const productsIds = await this.getProductIds(category, filters, optionsCache);
|
|
@@ -1532,6 +1544,12 @@ class CategorySearchStrategy {
|
|
|
1532
1544
|
const productCatalog = this.repositoryService.getProductCatalog();
|
|
1533
1545
|
const filterHelper = this.helpersService.getFilterHelper();
|
|
1534
1546
|
const sortHelper = this.helpersService.getSortHelper();
|
|
1547
|
+
console.warn('searchDefault repoParams', {
|
|
1548
|
+
filters: {
|
|
1549
|
+
...(await productCatalog.categoryStructureAdapter.buildProductFilterByCategory(category)),
|
|
1550
|
+
...filterHelper.buildFilterQuery(filters || {}),
|
|
1551
|
+
},
|
|
1552
|
+
});
|
|
1535
1553
|
const repoParams = {
|
|
1536
1554
|
fields,
|
|
1537
1555
|
filters: {
|
|
@@ -1551,6 +1569,10 @@ class CategorySearchStrategy {
|
|
|
1551
1569
|
async getProductIds(category, filters, optionsCache) {
|
|
1552
1570
|
const productCatalog = this.repositoryService.getProductCatalog();
|
|
1553
1571
|
const filterHelper = this.helpersService.getFilterHelper();
|
|
1572
|
+
console.warn('getProductIds filters', {
|
|
1573
|
+
...(await productCatalog.categoryStructureAdapter.buildProductFilterByCategory(category)),
|
|
1574
|
+
...filterHelper.buildFilterQuery(filters || {}),
|
|
1575
|
+
});
|
|
1554
1576
|
return productCatalog.productRepository
|
|
1555
1577
|
.findCatalog({
|
|
1556
1578
|
fields: ['id'],
|
|
@@ -1567,6 +1589,10 @@ class CategorySearchStrategy {
|
|
|
1567
1589
|
const filterHelper = this.helpersService.getFilterHelper();
|
|
1568
1590
|
const sortHelper = this.helpersService.getSortHelper();
|
|
1569
1591
|
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(productIds))];
|
|
1592
|
+
console.warn('findAndSortByMostRelevant', {
|
|
1593
|
+
id: { operator: Where.IN, value: mostRelevantProductsIds },
|
|
1594
|
+
...filterHelper.buildFilterQuery(filters || {}),
|
|
1595
|
+
});
|
|
1570
1596
|
const totalResult = await productCatalog.productRepository.findCatalog({
|
|
1571
1597
|
fields,
|
|
1572
1598
|
filters: {
|
|
@@ -1821,12 +1847,17 @@ class CategoryService {
|
|
|
1821
1847
|
this.shop = shop;
|
|
1822
1848
|
}
|
|
1823
1849
|
async fetchBrands(category, options, optionsCache) {
|
|
1850
|
+
const filters = await this.productCatalog.categoryStructureAdapter.buildProductFilterByCategory(category);
|
|
1851
|
+
console.warn('fetchBrands', filters);
|
|
1824
1852
|
const brands = await this.productCatalog.productRepository
|
|
1825
1853
|
.findCatalog({
|
|
1826
1854
|
filters: await this.productCatalog.categoryStructureAdapter.buildProductFilterByCategory(category),
|
|
1827
1855
|
fields: ['brand'],
|
|
1828
|
-
},
|
|
1856
|
+
}, null,
|
|
1857
|
+
// options?.mainGender ? options?.mainGender : this.shop === Shops.MENSMARKET ? 'male' : 'female',
|
|
1858
|
+
optionsCache)
|
|
1829
1859
|
.then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => ({ ...brands, [brand]: true }), {})));
|
|
1860
|
+
console.warn('brands', brands);
|
|
1830
1861
|
return this.categoryFacade.categoryRepository
|
|
1831
1862
|
.find({ filters: { brandCategory: true, shop: options?.shop || this.shop }, orderBy: { name: 'asc' } }, optionsCache)
|
|
1832
1863
|
.then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
|
|
@@ -2164,6 +2195,7 @@ class CatalogService {
|
|
|
2164
2195
|
async fetchProducts(options, optionsCache) {
|
|
2165
2196
|
this.validateRequest(options);
|
|
2166
2197
|
const searchParams = this.buildSearchParams(options);
|
|
2198
|
+
console.warn('fetchProducts', searchParams);
|
|
2167
2199
|
const { data, count: total, maximum, minimal, distinct, } = await this.searchContext.executeSearch(searchParams, this.shop, optionsCache);
|
|
2168
2200
|
await this.helpersService.getBrandManager().setBrandsList(searchParams, distinct?.brand);
|
|
2169
2201
|
return this.buildResponse({
|