Product Picker
Last updated
Last updated
The product picker app slice helps you easily integrate product data into your content.
The app slice consists of a web component that communicates with a private GraphQL API on top of the Ucommerce product search index.
The following three tasks are needed to integrate the product picker into your solution.
Load the web component into your content management system by importing the app slice javascript file into your page. Ucommerce hosts the web component on the following URL, which you can reference on runtime:
Then you can use the new HTML tag on your page.
Notice that the credentials are available in the HTML so this should not be used in publicly available parts of your website.
The ucommerce-product-picker
element will emit an event product-selection
, with the IDs of the selected products, when the user clicks the add button. These IDs can then be saved and used for fetching all the product data from the API built in the next step.
We have a short Umbraco custom property editor example that you can use for inspiration.
You will need an endpoint in Ucommerce to fetch the product data when your store generates the page with the picked products.
A solution could be to create a controller extending the HeadlessControllerBase
class using the Search APIs to get your product data. See custom headless APIs for more details.
The last piece in the puzzle is to generate your page using the product data from your endpoint using the product IDs returned by the picker.
We recommend fetching the product data at this time, to ensure that the product information is always up to date. If prices, descriptions, etc. change in Ucommerce, you would want the information to flow to the website without delay.