Skip to content

Commit 62b686c

Browse files
committed
Manual updated
1 parent a27b12e commit 62b686c

File tree

4 files changed

+51
-20
lines changed

4 files changed

+51
-20
lines changed

README.md

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -111,37 +111,43 @@ There is searchbar in the header of the shop.
111111
<img src="doc/es_browser.png" />
112112
</div>
113113

114-
You can easily modify it by overriding the `@BitBagSyliusElasticsearchPlugin/Shop/Menu/_searchForm.html.twig` template or disable it by setting:
114+
You can easily modify it by overriding the `@BitBagSyliusElasticsearchPlugin/Shop/Layout/Header/searchForm.html.twig` and templates `@BitBagSyliusElasticsearchPlugin/Shop/SearchForm/searchForm.html.twig` or disable it by setting:
115115
```yml
116-
sylius_ui:
117-
events:
118-
sylius.shop.layout.header.content:
119-
blocks:
120-
bitbag_es_search_form:
121-
enabled: false
116+
sylius_twig_hooks:
117+
hooks:
118+
'sylius_shop.base.header.content':
119+
search_form:
120+
template: "@BitBagSyliusElasticsearchPlugin/Shop/Layout/Header/searchForm.html.twig"
121+
priority: 250
122+
enabled: false
123+
'sylius_shop.base.header.content.search_form':
124+
content:
125+
component: 'bitbag.sylius_elasticsearch_plugin:search_form'
126+
props:
127+
template: "@BitBagSyliusElasticsearchPlugin/Shop/SearchForm/searchForm.html.twig"
128+
priority: 0
129+
enabled: false
122130
```
123-
124131
### Searching taxon products
125132
126-
When you go now to the `/{_locale}/products-list/{taxon-slug}` page, you should see a totally new set of filters. You should see something like this:
133+
When you go now to the ` /{_locale}/taxons/{slug}` page, you should see a totally new set of filters. You should see something like this:
127134

128135
<div align="center">
129136
<img src="doc/es_results.png" />
130137
</div>
131138

132-
You might also want to refer the horizontal menu to a new product list page. Follow below instructions to do so:
133-
134-
1. If you haven't done it yet, create two files:
135-
* `_horizontalMenu.html.twig` in `templates/bundles/SyliusShopBundle/Taxon` directory
136-
* `_breadcrumb.html.twig` in `templates/bundles/SyliusShopBundle/Product/Show` directory
137-
2. Paste into those files content of respectively `vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/views/Taxon/_horizontalMenu.html.twig` and `vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/views/Product/Show/_breadcrumb.html.twig` files, replacing `sylius_shop_product_index` with `bitbag_sylius_elasticsearch_plugin_shop_list_products` in both of them.
138-
3. Clean your cache with `bin/console cache:clear` command.
139-
4. :tada:
139+
It is important that the `routing.yml` from the plugin are loaded before `sylius_shop`:
140140

141-
If you're using vertical menu - follow steps above with `_verticalMenu.html.twig` file instead. It's in the same directory as the `_horizontalMenu.html.twig` file.
142-
143-
**Be aware! Elasticsearch does not handle dashes well. This plugin depends on the code field in Sylius resources. Please use underscores instead of dashes in your code fields.**
141+
```yaml
142+
bitbag_sylius_elasticsearch_plugin:
143+
resource: "@BitBagSyliusElasticsearchPlugin/config/routing.yml"
144144
145+
sylius_shop:
146+
resource: "@SyliusShopBundle/Resources/config/routing.yml"
147+
prefix: /{_locale}
148+
requirements:
149+
_locale: ^[A-Za-z]{2,4}(_([A-Za-z]{4}|[0-9]{3}))?(_([A-Za-z]{2}|[0-9]{3}))?$
150+
```
145151
### Excluding options and attributes in the filter menu
146152

147153
You might not want to show some specific options or attributes in the menu. You can set specific parameters for that:
@@ -212,6 +218,29 @@ fos_elastica:
212218

213219
Indexes with `bitbag_shop_product`, `bitbag_attribute_taxons` and `bitbag_option_taxons` keys are available so far.
214220

221+
### Search fuzziness
222+
223+
>Fuzziness in Elasticsearch is a feature that allows search queries to match terms even if there are minor typos or spelling mistakes.
224+
It works by calculating the Levenshtein distance (edit distance) between the query term and indexed terms, enabling the search engine to find similar words—for example, a search for “aple” can still match “apple.”
225+
Fuzziness is commonly used in full-text search to improve result accuracy despite small user input errors.
226+
227+
You can set the fuzziness of the search by overriding the `bitbag_sylius_elasticsearch_plugin.query_builder.contains_name` service in your service file `(min. -> 0, max. -> 2)`:
228+
```xml
229+
<service id="bitbag_sylius_elasticsearch_plugin.query_builder.contains_name" class="BitBag\SyliusElasticsearchPlugin\QueryBuilder\ContainsNameQueryBuilder">
230+
<argument type="service" id="sylius.context.locale" />
231+
<argument type="service" id="bitbag_sylius_elasticsearch_plugin.search_property_name_resolver_registry" />
232+
<argument type="string">AUTO</argument>
233+
</service>
234+
```
235+
236+
```yaml
237+
bitbag_sylius_elasticsearch_plugin.query_builder.contains_name:
238+
class: BitBag\SyliusElasticsearchPlugin\QueryBuilder\ContainsNameQueryBuilder
239+
arguments:
240+
- '@sylius.context.locale'
241+
- '@bitbag_sylius_elasticsearch_plugin.search_property_name_resolver_registry'
242+
- 'AUTO'
243+
```
215244

216245
## Customization
217246

doc/es_browser.png

554 KB
Loading

doc/es_results.png

1.25 MB
Loading

doc/installation.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ imports:
5959
```
6060
6161
Import routing on top of your `config/routes/sylius_shop.yaml` file:
62+
63+
#### IMPORTANT!
6264
**Note.** The code presented below needs to be loaded before including the `sylius_shop` routes. Please be sure, that it's being loaded first.
6365

6466
```yaml

0 commit comments

Comments
 (0)