-
Notifications
You must be signed in to change notification settings - Fork 0
CMS Context
Before you continue, make sure the required integration steps have been completed.
The CMS context can be used on any page in your e-shop. The content of the response depends 100% on your design and layout blocks desired.
The content of the response depends 100% on your design and layout blocks desired.
Before you start, the layout blocks & narrative layout must be defined in Boxalino Intelligence admin.
The Layout Blocks JSON & Narratives JSON from this page can be used as base.
If there is no narrative assigned to the choice/widget requested, the response will be empty.
In the Layout Blocks JSON & Narrative Layout JSON sample provided , a "home" widget will be added to the home page (ex: a list of products).
The provided JSON samples for the Narrative layout and the Layout blocks must be imported in Boxalino Intelligence Admin
In order to add a CMS block or create a CMS page containing an API request, the following steps are needed:
For the product list sample, it has been configured to show:
- the title (h3)
- a listing with dynamic product items.
In the most basic integration (ex: when extending from the provided base ContextAbstract ) - only 3 functions are left to be implemented in order to set:
- the products visibility (as filter values)
- the products category (as filter - depends on the context)
- the return fields (which can be set via layout XML as well)
The filters list can be changed by rewriting the addFilters(RequestInterface $request) function.
FYI: the request definition must be defined on the context. For the CMS context scenario - where there is no search query/subphrases or other context-specific properties required - the ListingRequestDefinitionInterface is sufficient. Based on your requirements, a different request definition can be used.
The CMS block can be generic and can be re-usable.
The API request is done on protected function _prepareLayout()
.
4. Use the block in a layout XML or for widget definitions, etc
When using the block, make sure to set the widget, hitCount, groupBy and the return fields (if desired). These properties are required on the ContextInterface object (step #1).
For this use-case it has been used the generic template from RTUX Magento2 which will render the content of the JSON API response in a loop.
[ { "id": 810, "uniqueKey": "product_list_api", "parametersJsonScheme": "{\n \"title\": \"Product List\",\n \"type\": \"object\",\n \"properties\": {\n \"accessor\": {\n \"type\": \"string\",\n \"description\": \"hits accessor (typically leave empty)\"\n }\n }\n}", "format": null, "widgets": [], "parameters": [ { "name": "bx-hits", "values": [ "accessor" ] }, { "name": "template", "values": [ "BoxalinoClientProject_BoxalinoIntegration::api/catalog/product/listing.phtml" ] }, { "name": "type", "values": [ "Boxalino\\RealTimeUserExperience\\Block\\Catalog\\Product\\ListProduct" ] }, { "name": "model", "values": [ "Boxalino\\RealTimeUserExperience\\Model\\Response\\Content\\ApiEntityCollection" ] }, { "name": "content-resource", "values": [ "c-r=t" ] }, { "name": "name", "values": [ "rtux_api_product_list" ] } ], "subRenderings": [], "route": "visual-elements", "reqParams": null, "$fromServer": true, "parentResource": null, "restangularCollection": false, "contentResource": false, "isSelected": true }, { "id": 815, "uniqueKey": "product", "parametersJsonScheme": "{\n \"title\": \"Product\",\n \"type\": \"object\",\n \"properties\": {\n \"accessor\": {\n \"type\": \"string\",\n \"description\": \"hits accessor (typically leave empty)\"\n }\n }\n}", "format": null, "widgets": [], "parameters": [ { "name": "template", "values": [ "BoxalinoClientProject_BoxalinoIntegration::api/catalog/product/list/item.phtml" ] }, { "name": "bx-hit", "values": [ "accessor" ] }, { "name": "content-resource", "values": [ "c-r=t" ] }, { "name": "name", "values": [ "rtux_api_product_item" ] }, { "name": "type", "values": [ "Boxalino\\RealTimeUserExperience\\Block\\Catalog\\Product\\ProductList\\Item\\Block" ] } ], "subRenderings": [], "route": "visual-elements", "reqParams": null, "$fromServer": true, "parentResource": null, "restangularCollection": false, "contentResource": false, "isSelected": true }, { "id": 917, "uniqueKey": "title_h3", "parametersJsonScheme": "{\n \"title\": \"Title (H3)\",\n \"type\": \"object\",\n \"properties\": {\n \"title\": {\n \"type\": \"object\",\n \"title\": \"Title\",\n \"properties\": {\n \"de\": {\n \"type\": \"string\",\n \"description\": \"title in German\"\n },\n \"en\": {\n \"type\": \"string\",\n \"description\": \"title in English\"\n }\n }\n }\n }\n}", "format": null, "widgets": [], "parameters": [ { "name": "template", "values": [ "BoxalinoClientProject_BoxalinoIntegration::api/element/title-h3.phtml" ] }, { "name": "content-resource", "values": [ "c-r=t" ] }, { "name": "name", "values": [ "rtux_api_title_h3" ] }, { "name": "type", "values": [ "Boxalino\\RealTimeUserExperience\\Block\\Api\\Block" ] } ], "subRenderings": [], "route": "visual-elements", "reqParams": null, "$fromServer": true, "parentResource": null, "restangularCollection": false, "isSelected": true } ]
[ { "id": 816, "status": null, "uniqueKey": "home", "aliases": null, "widgets": [ "home" ], "allWidgets": null, "parametersJsonScheme": null, "seoContent": { "title": [ { "language": "de", "value": "" } ], "metaTags": [], "h1": [ { "language": "de", "value": "" } ], "others": [ { "name": "breadcrumbs", "value": [ { "language": "de", "value": "" } ] } ] }, "contexts": [], "layoutModels": null, "acts": [ { "parameters": [ null ], "chapter": { "format": "CPOActChapter", "contexts": [], "subActs": [], "journeyStepUniqueKeys": null, "callToActions": null, "renderings": [ { "parameters": [ null ], "rendering": { "contexts": [], "layoutModels": [], "visualElements": [ { "visualElementModelUniqueKey": "title_h3", "label": "Recommendation Title", "parameters": [ { "name": "title", "values": [ "{\"de\":\"Ihre persöhnliche Empfehlungen\",\"en\":\"Our recommendations for you\"}" ] } ], "visualElement": null, "subRenderings": [ { "parameters": [ null ], "rendering": { "contexts": [], "layoutModels": [], "visualElements": [], "parameters": null } } ] }, { "visualElementModelUniqueKey": "product_list_api", "label": "Product List", "parameters": [ { "name": "accessor", "values": [ "" ] } ], "visualElement": null, "subRenderings": [ { "parameters": [ null ], "rendering": { "contexts": [], "layoutModels": [], "visualElements": [ { "visualElementModelUniqueKey": "product", "label": "Dynamic Product", "parameters": [ { "name": "accessor", "values": [ "" ] } ], "visualElement": null, "subRenderings": [ { "parameters": [ null ], "rendering": { "contexts": [], "layoutModels": [], "visualElements": [], "parameters": null } } ] } ], "parameters": null } } ] } ], "parameters": null } } ], "parameters": null } } ], "parameters": [], "route": "narratives", "reqParams": null, "$fromServer": true, "parentResource": null, "restangularCollection": false, "isSelected": true } ]
© 2021 Boxalino AG | Real Time User Experience API | Integration | Magento2