Skip to content

Commerce Search Refinement doesn't work with picklist fields #72

@LukaszSzczygielski

Description

@LukaszSzczygielski

Hi,
I am implementing commerce search using Connect API
Rest Connect API
Apex Connect API
Unfortunately I cannot filter search results by picklist field value.
B2B Commerce on Lightning Doc states that picklist type is supported.

This is a sample of my code:

`

     CommerceSearchDomain.SearchProductsWrapper searchProductsWrapper = new CommerceSearchDomain.SearchProductsWrapper();

    searchProductsWrapper.webstoreId = input.webstoreId;

    searchProductsWrapper.productSearchInput = new ConnectApi.ProductSearchInput();

    searchProductsWrapper.productSearchInput.pageSize = APP_CommerceCatalogAPI.DEFAULT_SEARCH_PRODUCTS_SIZE;

    searchProductsWrapper.productSearchInput.page = input.pageNumber;

    searchProductsWrapper.productSearchInput.searchTerm = input.searchTerm;

    ConnectApi.DistinctValueRefinementInput refinementInput = new ConnectApi.DistinctValueRefinementInput();

    refinementInput.values = new List<String>{'HE'};

    refinementInput.nameOrId = 'Orders_3__c';

    refinementInput.type = ConnectApi.CommerceSearchFacetType.DistinctValue;

    refinementInput.attributeType = ConnectApi.CommerceSearchAttributeType.Custom;

    searchProductsWrapper.productSearchInput.refinements = new List<ConnectApi.RefinementInput>{refinementInput};

`

Picklist field values:
image

Running SOQL as B2B user returns Product records with correct value in specified field.
But commerce search returns an empty response whenever I try to specify value in Refinement. For empty refinements list it returns every record (accessible by user).

I tried to check other fields and using Checkbox field gives proper results from the Webstore Search.

Before using fields as search filters I configure commerce setup and rebuild search index
image

Any ideas what is missing in my code or configuration? Anyone had this issue before?

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