Class SearchFilterUtil
java.lang.Object
org.broadleafcommerce.core.web.search.SearchFilterUtil
SearchFilterUtil exposes a simple static method for filtering out products that do not match the
criteria POSTed to a controller by a
SearchFilterTag.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidfilterProducts iterates over the products for each allowed parameter, filtering out products that do not match the values passed in via the parameters argument.
-
Constructor Details
-
SearchFilterUtil
public SearchFilterUtil()
-
-
Method Details
-
filterProducts
public static void filterProducts(List<Product> products, Map<String, String[]> parameters, String[] allowedParameters) filterProducts iterates over the products for each allowed parameter, filtering out products that do not match the values passed in via the parameters argument. There are 2 ways that a product can be filtered out, corresponding to the multiSelect and sliderRange displayTypes onSearchFilterItemTag. For multiSelect items, the method will remove the product if the property specified in allowedParameters's toString() method returns a String equal to one of the Strings in the corresponding String[] in parameters. For sliderRange items, the property on the product must be of typeMoney. The product will be filtered out if it's property is greater than the Money value parsed out of max-(property name) or smaller than the Money value parsed from min-(property name)- Parameters:
products- the list of products to filterparameters- the parameters passed to the controller. Generally request.getParameterMap()allowedParameters- an array of the allowed parameters to filter on
-