adobe / aem-core-cif-components

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

category_uid does not filter the product list #964

Open nitinharikant opened 1 year ago

nitinharikant commented 1 year ago

Expected Behaviour

products are filtered based on category uid in the query param

Actual Behaviour

All the products are shown in PLP page even though we have query parameter category_uid= category_uid=NA==

Reproduce Scenario (including but not limited to)

Create a page using CIF examples PLP component In the same page add query param category_uid = categoryid=NA== or Nw== depends on category the products on PLP are not filtered it works fine for category id https://www.aemcomponents.dev/content/core-components-examples/library/commerce/search.html?category_id=3&search_query=test

Steps to Reproduce

Create a page using CIF examples PLP component In the same page add query param category_uid = categoryid=NA== or Nw== depends on category the products on PLP are not filtered

Platform and Version

AEM6.5.12 and CIF 2.11.0

Sample Code that illustrates the problem

image

Logs taken while reproducing problem

NA

buuhuu commented 1 year ago

This is behaviour works as designed. For product listing we consider the following two cases:

1) product search

For product search the category context is not given by the url usually (meaning no category identifier is encoded in the url). In this case we do not remove the category aggregations from the search result set which allows the user to filter using the category facet. This facet is using the category_id only afaik

2) product list pages

For product lists on a product list page the category context is given by the url (meaning the url contains the url_path or url_key of the category). In this case the category id aggregation is limited to the direct children of the current category for facet navigation. This is the case because we don't want to filter, but navigate to the actual child categories plp to leverage caching (which would not be the case when using a ?category_id= request parameter). The cateogry id aggregation does not provide enough information to generate these links the plps, hence this information is queried with the category query.

cqueener commented 1 year ago

Hello, we are experiencing the same problem. The Search Result returns the aggregations - amongst them the categories - and when I try to filter by category on the result page the following URL params are created and sent: ?category_uid=103490&search_query=akkus which results in a GraphQL Exception: "message": "Value of uid \"128442\" is incorrect.", "extensions": { "category": "graphql-input" }, Manually changing the URL Param to category_id rather then UID returns results. With the category_uid Param the SearchResultServiceImpl always returns null

category = ((AbstractCategoryRetriever)categoryRetriever).fetchCategory();
                if (category == null) {
                    LOGGER.debug("Category not found.");
                    return new ImmutablePair((Object)null, searchResultsSet);
                }