Skip to content

Product List Sorting Options Not Working As Expected #883

Closed
@brandonmaynard

Description

@brandonmaynard

Expected Behaviour

When adding both ACS & DESC sorting for the same key, the UI select should have each option with different values and only one 'selected' at a time.

Actual Behaviour

When adding both ACS & DESC for the same key, the UI has each option, but they have the same value and both are selected

Reproduce Scenario (including but not limited to)

Modify the ProductListImpl to add price with sorting options with ASC & DESC for the same key.
searchOptions.addSorterKey("price", "Price (low to high)", Sorter.Order.ASC);
searchOptions.addSorterKey("price", "Price (high to low)", Sorter.Order.DESC);

On the UI, the sorting dropdown has both Price (low to high) and Price (high to low) options, but they are both selected and they both have the same value (with sort_order=asc).

Steps to Reproduce

See above

Platform and Version

AEMaaCS - aem-sdk-quickstart-2022.2.6433.20220223T194056Z-220100.jar

Sample Code that illustrates the problem

On https://github.com/adobe/aem-core-cif-components/blob/master/bundles/core/src/main/java/com/adobe/cq/commerce/core/search/internal/services/SearchResultsServiceImpl.java I think we need to modify the condition and check for both key and order from the params:
if (sortKeyParam.equals(key.getName()) && sortOrder.equals(key.getOrder())) {
keyImpl.setSelected(true);
sorter.setCurrentKey(key);
keyOrder = sortOrder;
resultSorterKey = keyImpl;
} else if (keyOrder == null) {
keyOrder = sortOrder;
}

Logs taken while reproducing problem

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions