-
Notifications
You must be signed in to change notification settings - Fork 1
Autocomplete (Server Fallback)
Please be aware that there have to be designed Layout Blocks in Boxalino Intelligence Admin
Make sure there is a narrative linked to the widget "autocomplete"
JSON samples of both elements are provided with these guidelines and must be imported in your Boxalino Intelligence Admin panel. Make sure to replace the @BoxalinoRealTimeUserExperienceIntegration namespace with your project`s
Boxalino recommends to have a JS integration of the autocomplete. The JSON elements can be imported from there directly. The server fallback strategy described before is only used if/when the JS requests fail.
https://github.com/boxalino/rtux-integration-shopware/blob/master/src/Resources/config/services/api/autocomplete.xml (widget name, context, etc)
-
the autocomplete request definition is available via an interface and has been declared as a service in BoxalinoRealTimeUserExperience
-
the autocomplete request context is done by extending the context abstract provided in the Framework
as an integrator, you can either build your own (following the sample) or extend it (it provides generic filters) for each use-case in order to set more filters if desired or other parameters (return fields, etc)
the Autocomplete[Context] will be the one to make the request by using an entity called RequestTransformer [https://github.com/boxalino/rtux-shopware/blob/master/src/Framework/Request/RequestTransformer.php] and adding extra filters per context: https://github.com/boxalino/rtux-shopware/tree/master/src/Framework/Request/ContextAbstract.php#L98
Shopware works with the concept of PageContentLoader, so there is one provided for the framework: https://github.com/boxalino/rtux-shopware/blob/master/src/Framework/Content/Page/ApiPageLoader.php
This content loader is generic and it has to be declared as a service. On it`s declaration, it is configured the ApiContextInterface which is context-specific (autocomplete, navigation, etc). The Autocomplete API Context and has been created&declared at the prior step.
Decorate the controller service by making use of the Autocomplete ApiPageLoader from step#2
The context ApiPageContentLoader is being used in the controller/cms pages/etc
The ApiPageLoader has access to Autocomplete[Context] request definition and to the ApiCallService The ApiPageLoader makes the call to the Boxalino API https://github.com/boxalino/rtux-shopware/blob/master/src/Framework/Content/Page/ApiPageLoader.php#L70
(more about decorating the SearchController in the Search Context guidelines)
It will be used in order to rewrite the actual suggest action. https://github.com/boxalino/rtux-integration-shopware/blob/master/src/Storefront/Controller/SearchController.php#L98
For the autocomplete, you can either use the response as it comes from Boxalino (without loading a collection of products) or define a model on the product list component and load each product as ProductEntity objects (more about the model https://github.com/boxalino/rtux-integration-shopware/blob/master/doc/search/INTEGRATION.md#L104 ) The templates can be found here: https://github.com/boxalino/rtux-integration-shopware/tree/master/src/Resources/views/storefront/narrative/layout/header/suggest
© 2021 Boxalino AG | Real Time User Experience API | Integration | Shopware6