@infrab4a/connect-angular 4.3.12-beta.16 → 4.3.12-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.
@@ -1540,6 +1540,7 @@ class NewCategoryStructureAdapter {
1540
1540
  }
1541
1541
  async buildProductFilterByCategory(category) {
1542
1542
  const loadedCategory = await this.getCategory(category);
1543
+ console.log('loadedCategory', loadedCategory);
1543
1544
  if (loadedCategory.isCollection)
1544
1545
  return { id: { operator: Where.IN, value: loadedCategory.products } };
1545
1546
  const categoryIds = [...(await this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
@@ -1558,9 +1559,16 @@ class NewCategoryStructureAdapter {
1558
1559
  .then((categories) => categories.map((category) => category.id.toString()));
1559
1560
  }
1560
1561
  async getCategory(category) {
1561
- return isNil(category.isCollection) || (category.isCollection && !category.products?.length)
1562
- ? this.categoryRepository.get({ id: category.id })
1563
- : category;
1562
+ const collectionCategory = category.isCollection ||
1563
+ isNil(category.isCollection) ||
1564
+ !category.products?.length ||
1565
+ category.isWishlist ||
1566
+ category.brandCategory;
1567
+ console.log('getCategory', category, collectionCategory);
1568
+ // return isNil(category.isCollection) || (category.isCollection && !category.products?.length)
1569
+ // ? this.categoryRepository.get({ id: category.id })
1570
+ // : category
1571
+ return collectionCategory ? this.categoryRepository.get({ id: category.id }) : category;
1564
1572
  }
1565
1573
  }
1566
1574
  NewCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -1625,22 +1633,17 @@ class CatalogService {
1625
1633
  if (!sort || sort === 'most-relevant')
1626
1634
  return {};
1627
1635
  if (sort === 'best-sellers')
1628
- return {
1629
- shoppingCount: 'desc',
1630
- rate: 'desc',
1631
- stock: 'desc',
1632
- name: 'asc',
1633
- };
1636
+ return { shoppingCount: 'desc' };
1634
1637
  if (sort === 'biggest-price')
1635
- return { subscriberPrice: 'desc', rate: 'desc', shoppingCount: 'desc' };
1638
+ return { subscriberPrice: 'desc' };
1636
1639
  if (sort === 'lowest-price')
1637
- return { subscriberPrice: 'asc', rate: 'desc', shoppingCount: 'desc' };
1640
+ return { subscriberPrice: 'asc' };
1638
1641
  if (sort === 'best-rating')
1639
- return { rate: 'desc', shoppingCount: 'desc', stock: 'desc', name: 'asc' };
1642
+ return { rate: 'desc' };
1640
1643
  if (sort === 'news')
1641
1644
  return { createdAt: 'desc' };
1642
1645
  if (sort === 'biggest-discount')
1643
- return { subscriberDiscountPercentage: 'desc', rate: 'desc', shoppingCount: 'desc' };
1646
+ return { subscriberDiscountPercentage: 'desc' };
1644
1647
  };
1645
1648
  this.buildLimitQuery = (options) => {
1646
1649
  const limit = options?.perPage || 20;
@@ -1680,9 +1683,16 @@ class CatalogService {
1680
1683
  return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
1681
1684
  }
1682
1685
  if (this.hasCategory(options) && options.sort === 'most-relevant') {
1683
- const productsIds = options.category.products?.length
1684
- ? options.category.products
1685
- : await this.categoryRepository.get({ id: options.category.id }).then((categoryFound) => categoryFound.products);
1686
+ const productsIds = await this.productRepository
1687
+ .find({
1688
+ filters: {
1689
+ ...(await this.buildMainFilter(options)),
1690
+ },
1691
+ })
1692
+ .then((products) => products.data.map((product) => product.id));
1693
+ // const productsIds = options.category.products?.length
1694
+ // ? options.category.products
1695
+ // : await this.categoryRepository.get({ id: options.category.id }).then((categoryFound) => categoryFound.products)
1686
1696
  return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
1687
1697
  }
1688
1698
  const repoParams = {