Build recommendation interfaces
Build recommendation interfaces
|
|
Atomic for Commerce components are in open beta and remain under active development. Atomic for Commerce hasn’t yet gone through a formal accessibility review. If you have accessibility needs, contact your customer success manager and we’ll work with you to address them. |
You can use the atomic-commerce-recommendation-list component to display a list of product recommendations by applying one or more product templates.
Wrap one or more recommendation lists in the atomic-commerce-recommendation-interface component.
Prerequisites
Before you begin building your recommendation interfaces, make sure you:
Code Sample
Following is a minimal example of a search interface built with Atomic for Commerce.
This uses getSampleCommerceEngineConfiguration from @coveo/headless/commerce for its configuration.
This won’t work in a production environment.
For a detailed breakdown of how to configure your recommendation interface, refer to the Coveo Headless documentation for
CommerceEngineConfiguration.
<html>
<head>
<title>Example Recommendation Page</title>
<script
type="module"
src="https://static.cloud.coveo.com/atomic/v3/atomic.esm.js">
</script>
<link
rel="stylesheet"
href="https://static.cloud.coveo.com/atomic/v3/themes/coveo.css"/>
<script type="module">
(async () => {
const {
buildCommerceEngine,
getSampleCommerceEngineConfiguration
} = await import('http://static.cloud.coveo.com/headless/v3/commerce/headless.esm.js');
await customElements.whenDefined('atomic-commerce-recommendation-interface');
const commerceInterface = document.querySelector('atomic-commerce-recommendation-interface');
await commerceInterface.initializeWithEngine(
buildCommerceEngine({
configuration: getSampleCommerceEngineConfiguration(),
})
);
})();
</script>
</head>
<body>
<atomic-commerce-recommendation-interface>
<atomic-commerce-recommendation-list
display="list"
density="normal"
image-size="small"
products-per-page="3"
slot-id="af4fb7ba-6641-4b67-9cf9-be67e9f30174"
>
</atomic-commerce-recommendation-interface>
</body>
</html>
| Import the Atomic for library. This is responsible for handling the web components. | |
| Link the Coveo theme stylesheet. This provides the default styling for the web components. | |
Import the Headless for Commerce library to get the sample configuration and the engine builder. When providing your own configuration you won’t
need to getSampleCommerceEngineConfiguration. |
|
Initialize the atomic-commerce-recommendation-interface. |
|
| The recommendation list for the interface. | |
| The identifier used by the Commerce API to retrieve the recommendation list for the component. |
You can find a complete example of a recommendation carousel in Storybook.