integration_documentation:plugin:en:integration:shopware_5:extension
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
integration_documentation:plugin:en:integration:shopware_5:extension [2022/04/21 12:17] tobi Add documentation for custom sorting |
integration_documentation:plugin:en:integration:shopware_5:extension [2022/04/21 18:17] (current) daniel |
||
---|---|---|---|
Line 265: | Line 265: | ||
``` | ``` | ||
- | ## (Requires 11.5.2) Add custom sorting options for API Integration (WIP) | + | ## Add custom sorting options for API Integration |
- | The Findologic base plugin already provides sorting options for the most common use-cases. The plugin uses `SortingHandler` to send the currently selected sorting option via API parameters to the Findologic Search-API (see [all available SortingHandlers](https://github.com/findologic/plugin-shopware-5/tree/main/FinSearchUnified/Bundle/SearchBundleFindologic/SortingHandler)). | + | </markdown> |
+ | <note important>Requires Findologic Plugin v11.5.2 or above</note> | ||
+ | <markdown> | ||
- | Therefore to handle custom sorting options, create a custom `SortingHandler` in the extension plugin, and override the responsible `QueryBuilderFactory` to include the created `SortingHandler`. | + | The Findologic plugin already provides sorting options for the most common use-cases. The plugin uses `SortingHandler` to send the currently selected sorting option via API parameters to the Findologic Search-API (see [all available SortingHandlers](https://github.com/findologic/plugin-shopware-5/tree/main/FinSearchUnified/Bundle/SearchBundleFindologic/SortingHandler)). |
+ | |||
+ | To handle custom sorting options, create a custom `SortingHandler` in the extension plugin, and override the responsible `QueryBuilderFactory` to include the created `SortingHandler`. | ||
Supported Shopware 5 sortings by default: | Supported Shopware 5 sortings by default: | ||
Line 376: | Line 380: | ||
**Step 3: Decorate the `QueryBuilderFactory`** | **Step 3: Decorate the `QueryBuilderFactory`** | ||
- | The `QueryBuilderFactory` registers all the available sorting options. Therefore, you want to add your custom sort to this factory. | + | The `QueryBuilderFactory` registers all the available sorting options. Add your custom sort to this factory. |
Create the folder structure `Bundle/SearchBundleFindologic/QueryBuilder` in the extension plugin, and add the file `QueryBuilderFactory`. Override the `registerSortingHandlers` method and add your handler to the array. | Create the folder structure `Bundle/SearchBundleFindologic/QueryBuilder` in the extension plugin, and add the file `QueryBuilderFactory`. Override the `registerSortingHandlers` method and add your handler to the array. | ||
Line 407: | Line 411: | ||
**Step 4: Add the decorated factory to the services.xml** | **Step 4: Add the decorated factory to the services.xml** | ||
- | As a last step, simply decorate it in your `Resources/services.xml`: | + | Finally decorate it in your `Resources/services.xml`: |
```xml | ```xml |