forcedotcom / forcedotcom/b2b-commerce-on-lightning-quickstart

Commerce Search Refinement doesn't work with picklist fields

Open
#72 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Shell
Stars
191
Forks
211
PR merge metrics
No merged PRs in 30d

Description

Hi,
I am implementing commerce search using Connect API
[Rest Connect API](https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/connect_resources_commerce_webstore_product_search.htm)
[Apex Connect API](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceSearch_static_methods.htm#apex_ConnectAPI_CommerceSearch_productSearch_1)
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{'HE'};

refinementInput.nameOrId = 'Orders_3__c';

refinementInput.type = ConnectApi.CommerceSearchFacetType.DistinctValue;

refinementInput.attributeType = ConnectApi.CommerceSearchAttributeType.Custom;

searchProductsWrapper.productSearchInput.refinements = new List{refinementInput};
`

Picklist field values:
![image](https://user-images.githubusercontent.com/81674221/200564272-c7e88b52-2251-4674-9f26-6a470a778fa5.png)

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](https://user-images.githubusercontent.com/81674221/200565120-3bbd67d0-5f7c-41b4-bfac-19f2301f49f5.png)

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.