Search code examples
javasap-commerce-cloud

SAP Hybris inStockFlag facet with just one option


I want to use inStockFlag facet with only one option checked. I've added it - it's extended from ProductInStockFlagValueProvider. It shows on the page, but it shows with both options TRUE and FALSE:

enter image description here

I only need one option and it is "In Stock" checked or not checked to filter products only InStock or all products:

enter image description here

I've tried to add custom valueDisplayNameProvider for this facet and return empty string in case of FALSE, but it's still displaying both options (just one is with empty string). I'm using SAP Hybris v1811.


Solution

  • I guess you can write a custom value provider to check if it has stock. If it has, you can provide the String "In Stock" as value.

    And if it doesn't have stock, you can return an empty Collection<FieldValue> from the method getFieldValues instead of providing an empty string.