API Components - boxalino/rtux-integration-magento2 GitHub Wiki
Dependencies
In order to integrate the Boxalino narrative API in your Magento2 project, the following dependencies are active:
- Boxalino RTUX API PHP repository
- Boxalino RTUX Magento2 repository
- Magento2 v2.3.5 or newer
Integration strategy
The integration plugin can be developed using the provided guidelines in the repository. The integration team has full control over the development, testing & deployment of the integration plugin. Each of the guidelines/use-cases described in the Wiki have links to point to the code. The code is providing additional comments which can help extend/rewrite the basse.
REQUEST component
TheThe main elements of a request are:
-
The Request Definition Interface is the data contract for the request: it describes the properties required for the API JSON request. Based on the context of the scenario used, the options are: autocomplete, item listing and search request definition.
-
The Request Context Interface is using the matching Request Definition Interface . This layer receives the framework Request entity, transforms it to a JSON request (by using the RequestTransformerInterface and the matching RequestDefintionInterface)
-
An API page loader is using the provided request context interface in order to make the API call. The output is the API response page which is then used in the block to access the content.
RESPONSE component
TheIt is possible to have access to a JSON response, but it is also possible to use accessor definitions in order to create objects from the JSON, maintaining the properties.
- The Accessor is configured in the DI by matching a Boxalino accessor (as configured in the layout block) to a definition, starting with the level of the "block".
For ex: bx-hit is accessed as a "product" property represented by the given model
-
The accessor should not be confused with the model property configured on the Layout Block. The model is used to specify the object in which the collection is accessed (ex: entity model for the bx-hits list, facet model for the bx-facets list, etc)
-
In Magento2 a Layout Block is defined by a type and template (per framework standards).
For ex: the product list can be replaced with a simpler model which can access the product collection by using the model on the Layout Block
Based on the most use-cases needs, an API renderer interface has been provided as a base for all API response block types.
For ex: the default block can be used with any template in order to access properties (getTitle(), etc) and create children blocks