adobe / aem-core-cif-components

A set of configurations and components to get you started with AEM Commerce development
Apache License 2.0
103 stars 80 forks source link

CIF-2720: improve linking to catalog specific product/category pages #922

Closed buuhuu closed 2 years ago

buuhuu commented 2 years ago

Description

Since #831 it is possible to maintain multiple product/category pages in a site by creating multiple catalog pages and a product/category page for each of them. So far that support was rather limited as the link generated by the various components did inherit the product/category page reference from the hierarchy and so were only able to link to objects in the current catalog page. For example, a product teaser in catalogpage1 would only link to the product page in the catalogpage1, even if the product should be shown using the product page in catalogpage2.

With this change support for linking between the product pages of various catalog pages was added. The SiteStructure interface was added to hide the implementation details. The methods getProductPages() and getCategoryPages() consider:

a) the direct catalog page children of the landing page (navigation root) and b) the landing page

For each of them the cq:cifCategoryPage and cq:cifProductPage properties are read and resolved to the corresponding page. The implementation also deals with Launches.

It is not necessary anymore to pass the product/category page to the UrlProvider. The UrlProvider implementation will use the SiteStructure interface to retrieve the product/category pages and will select the first matching one for a given product or category. The specific page logic is than applied on the selected generic product/category page as usual.

The Breadcrumb component now hides the category entries from the breadcrumb of a product/category page that are ancestors of the configured category of the catalog page. Only descendant categories will be included. (for show catalog page enabled).

Other changes:

Related Issue

CIF-2720

831

Motivation and Context

In use cases where the top level navigation is not built using the categories of the commerce backend as is but with regular pages, it may be desired to have one or many pages (catalogpage) to handle one specific section of a catalog and another one to handle the rest. This allows also for flexible sorting of the top level navigation entries.

How Has This Been Tested?

Unit tests, locally with wknd+commerce and venia

Screenshots (if appropriate):

Types of changes

Checklist:

codecov[bot] commented 2 years ago

Codecov Report

Merging #922 (a4fe7e5) into master (4392f97) will decrease coverage by 0.04%. The diff coverage is 88.72%.

@@             Coverage Diff              @@
##             master     #922      +/-   ##
============================================
- Coverage     89.73%   89.69%   -0.05%     
- Complexity     2018     2124     +106     
============================================
  Files           338      343       +5     
  Lines          9277     9499     +222     
  Branches       1318     1367      +49     
============================================
+ Hits           8325     8520     +195     
- Misses          678      700      +22     
- Partials        274      279       +5     
Flag Coverage Δ
integration 52.34% <46.36%> (-0.42%) :arrow_down:
jest 86.38% <ø> (ø)
karma 95.66% <ø> (ø)
unittests 88.75% <87.81%> (-0.08%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ls/v1/productcollection/ProductCollectionImpl.java 100.00% <ø> (ø)
...e/components/services/ComponentsConfiguration.java 100.00% <ø> (ø)
...commerce/core/components/utils/SiteNavigation.java 71.69% <ø> (-24.53%) :arrow_down:
...mponents/internal/models/v1/button/ButtonImpl.java 81.08% <50.00%> (+6.66%) :arrow_up:
...1/contentfragment/CommerceContentFragmentImpl.java 83.49% <50.00%> (ø)
...models/v1/relatedproducts/RelatedProductsImpl.java 77.55% <50.00%> (+2.55%) :arrow_up:
...ts/internal/models/v1/searchbar/SearchbarImpl.java 60.00% <50.00%> (-15.00%) :arrow_down:
...l/services/sitemap/CategoriesSitemapGenerator.java 81.53% <50.00%> (+0.94%) :arrow_up:
...nal/services/sitemap/ProductsSitemapGenerator.java 90.32% <50.00%> (+1.26%) :arrow_up:
...internal/servlets/CategoryPageRedirectServlet.java 90.90% <50.00%> (-0.76%) :arrow_down:
... and 43 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 4392f97...a4fe7e5. Read the comment docs.