Product Filter Searching

There are ‘search forms’ for Custom Modules so you can filter by item fields. Is there the same functionality for Products? We need to setup a filtering like this - but with more custom fields that have been added to products and can’t seem to find how we can access the field content for a search form.

Any custom property can be added to the search form by prepending its alias with prop_ for the input name.
The only other thing to adjust in the search form is the module ID.
So for example, my Products module ID is 1844 and I have a custom property called Cushion Material. The search form would be:

	<input type="hidden" name="prop_ModuleId" value="1844" >
	<input type="text" name="prop_KeyWords" maxlength="255" value="{{request.request_url.params.prop_KeyWords}}" >
    <label>Cushion Material</label>
    <input type="text" name="prop_CushionMaterial" value="{{request.request_url.params.prop_CushionMaterial}}" >
	<input type="submit" value="Search" >

{% component source: "Products", layout: "List", isSearchResult: "true", type: "module" %}

Keep in mind though, that all search fields currently use the AND condition so all search criteria have to match all those properties of the products to return a result. And each individual field needs to be an exact match as well.

OK great, thanks for the confirmation @Adam.Wilson. With a bit of playing I have been able to add all the custom filters and it looks to be working well.

@Adam.Wilson I’m having issues using a boolean field in Product Search. I created a field called ‘Under Offer’ and have tried -

 <input type="checkbox" name="prop_UnderOffer" id="prop_UnderOffer"> 
 <input type="checkbox" name="prop_underoffer" id="prop_underoffer"> 

Neither of these seem to work. Is there something I am missing here?

Hi @SiroccoDigital. I tested this with a Custom Module search with a boolean property and had the same result. No items were returned when checked.

This might be a bug, or it could be that booleans are excluded from search because they can be problematic.
eg: If you were to check a boolean checkbox in a search, it could return items with a value of true. But if the checkbox was left unchecked it would just be ignored and return all items - not just items with a value of false.

I think in most cases it’s more flexible to use a dropdown list (with true/false, yes/no, etc…) rather than a boolean.

Perhaps you can change the property to a dropdown? but might be worth submitting a ticket as well.

Thanks @Adam.Wilson I will submit a ticket about this. If I can’t resolve it, may need to swap it to a dropdown. Thanks for checking this out for me.

@Adam.Wilson to resolve this we added value=“true” and this now works.

@SiroccoDigital that’s great it’s working for you now.
In my test, using a Custom Module search, that’s what I had and it still doesn’t work. Must be working for Products module though for some reason.

Keep in mind though, unchecking the box will return all results, not just items with ‘false’.