-
Notifications
You must be signed in to change notification settings - Fork 1
Listing
In layout terms, a listing view has the following elements:
- collection of products
- facets
- toolbar
- pagination
- sorting options
The above elements can be mapped to Boxalino response accessors as well:
- bx-hits for product collection
- bx-hit for product item
- bx-pagination for pagination
- bx-sort for the sorter
- bx-hitCounts for toolbar
The blocks & rendering strategy part of the repository is used as guideline. The integrator has the responsibility to decide on how the JSON response is displayed. Make use of the additional code comments in order to make a decision or to get technical insight into the chosen strategy.
As presented in the integration repository JSON samples, the recommended/expected structure for a Layout Block includes 2 properties:
- model - the block content collection
- template - the block template (optional)
This matches the block accessor model declared as a dependency.
Per Shopware6 standard, the content is being handled by a Page Loader;
This is a declared dependency which is further extended in the integration layer. The only dynamic property on this component is the ApiContext which is added on new service declarations with the injector "setApiContext"
On a fully-narrative response view, the base template used is https://github.com/boxalino/rtux-shopware/blob/master/src/Resources/views/storefront/element/cms-element-narrative-page.html.twig or https://github.com/boxalino/rtux-shopware/blob/master/src/Resources/views/storefront/element/cms-element-narrative-page-sidebar.html.twig
Each of the API response blocks is being rendered based on the template and model configured in Boxalino Intelligence Admin >> Layout Blocks. For example: https://github.com/boxalino/rtux-shopware/blob/master/src/Resources/views/storefront/element/cms-element-narrative-content.html.twig#L25
All of the out-of-the-box Shopware6 elements can be found in the Framework/Content path.
- ApiPageLoader - having the ApiContext defined - it makes the API request;
- ApiResponsePage stores the API response sections (blocks, positions, etc)
- ApiEntityCollection is a model to be used as "model" property on the Layout Block for bx-hits; with it - a Shopware\Core\Framework\DataAbstractionLayer\Search\EntitySearchResult object is created with the product IDs from Boxalino
- ApiFacetModel is a model to be used for the "model" property on the Layout Block for bx-facets; more information avaialable in the Facets integration documentation
- ApiSortingModel can be used as preference for the rtux-api-php interface dependency
Due to the declared bx-X accessor values on the Boxalino Layout Blocks, the content returned by the API will be loaded into accessor models and available as properties on the block.
The AccessorHandlerInterface has access to the declared accessors.
For example, the pagination property matches the bx-pagination Layout Block accessor; based on this, the property is accessed in the Layout Block template directly block.pagination
Similar integration is available for toolbar, sorting, product lists, etc.