Skip to content
danneg edited this page Oct 12, 2020 · 5 revisions

In layout terms, a listing view has the following elements:

  1. collection of products
  2. facets
  3. toolbar
  4. pagination
  5. sorting options

The above elements can be mapped to Boxalino response accessors as well:

  1. bx-hits for product collection
  2. bx-hit for product item
  3. bx-pagination for pagination
  4. bx-sort for the sorter
  5. 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.

API Blocks

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.

Block rendering

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

Element definitions

All of the out-of-the-box Shopware6 elements can be found in the Framework/Content path.

  1. ApiPageLoader - having the ApiContext defined - it makes the API request;
  2. ApiResponsePage stores the API response sections (blocks, positions, etc)
  3. 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
  4. 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
  5. ApiSortingModel can be used as preference for the rtux-api-php interface dependency

Accessor

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.

Clone this wiki locally