Hi everyone, I would like to exclude certain items...
# suitecommerce
m
Hi everyone, I would like to exclude certain items from appearing via the typeAhead or the global search. These items can onnly be purchased as part of a kit item, and we want to avoid displaying these items when the client search somehitng in the typeAhead or global search. I have the item field custitem_exclude field to exclude these items from search and I have tried unsuccessfully to use the request parameters in the commerce item API: .../api/items?... For example: I have some request parameters like: fieldset=typeAhead&custitem_exclude=T&... but the response show always items with the custitem_exclude to true. I have tried the values T, true, 1, F, false, 0, ... and it seems that the custitem_exclude is not taken into account, the field has been added into the fieldsets correctly. I use the documentation here: https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_N2665676.html Am I missing something ? Or could you tell me if there is another way to exclude certain items so that they do not appear directly in the search ?
s
I would recommend that you create a pre-filter using a facet and defineSearchMasterOptions() https://system.netsuite.com/help/helpcenter/en_US/APIs/SuiteCommerce/Extensibility/Frontend/Environment.html#defineSearchMasterOptions
After setting up custitem_exclude as a facet, you can define master search options to pre-apply the facet with its false value. That will prevent those items from showing in search results
Something like this:
Copy code
mountToApp: function mountToApp (container) {
    var Environment = container.getComponent('Environment');

    if (Environment) {
        Environment.defineSearchMasterOptions('Facets', function (searchApiMasterOptions) {
            searchApiMasterOptions.custitem_exclude='true'
            return searchApiMasterOptions
        });
    }
}
(I forget the syntax for checkboxes, sorry, but I wrote about it here: https://developers.suitecommerce.com/whats-new-for-developers-in-netsuite-suitecommerce-20212.html#define-item-search-api-master-options)
👍 1
m
Excellent, it was missing adding the custom item field as a facet. I also defined the master search options with a false value and it works now. Thank you very much for your help 🙂
👍🏻 1