简体   繁体   English

SAP Hybris inStockFlag facet 只有一个选项

[英]SAP Hybris inStockFlag facet with just one option

I want to use inStockFlag facet with only one option checked.我想在只选中一个选项的情况下使用inStockFlag facet。 I've added it - it's extended from ProductInStockFlagValueProvider .我已经添加了它 - 它是从ProductInStockFlagValueProvider扩展而来的。 It shows on the page, but it shows with both options TRUE and FALSE :它显示在页面上,但同时显示了TRUEFALSE选项:

在此处输入图像描述

I only need one option and it is "In Stock" checked or not checked to filter products only InStock or all products:我只需要一个选项并且选中或未选中“有货”以仅过滤有货产品或所有产品:

在此处输入图像描述

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).我尝试为此方面添加自定义valueDisplayNameProvider并在FALSE的情况下返回空字符串,但它仍然显示两个选项(只有一个带有空字符串)。 I'm using SAP Hybris v1811.我正在使用 SAP Hybris v1811。

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.如果有,您可以提供字符串“In Stock”作为值。

And if it doesn't have stock, you can return an empty Collection<FieldValue> from the method getFieldValues instead of providing an empty string.如果它没有库存,您可以从方法getFieldValues返回一个空的Collection<FieldValue>而不是提供一个空字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM