Butik
Search…
Search
If you want to provide a search, there are multiple ways
Because products are a native collection, we can make use of the search functionality by Statamic: https://statamic.dev/search
Set up a search form in your antlers template, define a template for the results and you are finished.
What about a live search? Well, lucky I did create an addon for this case.
It provides updated results as you type but is hooking into the Statamic search as well. Use the local driver, an algolia driver or whatever you prefer.
Live Search - A Statamic addon
Live Search - a Statamic Addon
Statamic

Configure indexes

Whatever way you prefer, the main key is to configure those search indexes correctly. An example to get you started. Here we do have the default index for the page itself and a separate index for products. In your search you can leave out the index to serach through all indexes or define
default or products as index, to narrow down the search results.
1
// config/statamic/search.php
2
3
'default' => [
4
'driver' => 'local',
5
'searchables' => ['collection:pages'],
6
'fields' => ['title', 'url' ],
7
],
8
9
'products' => [
10
'driver' => 'algolia',
11
'searchables' => 'collection:products',
12
'fields' => ['title', 'url', 'price' ],
Copied!
Last modified 10mo ago