Availability Tutorial
How to specify availability, popularity, or stock level for a product
This tutorial describes how to specify availability, popularity, and stock level for a single product.
Information about a specific product's availability, popularity, and stock levels is stored inside the Availability
object.
Take a look at the relationships between the Availability
object and other resources in the Emporix Commerce Engine:
Before you start
Make sure you created a product. For more information, check out How to add your first product.
Create the Availability
object
Availability
objectTo add availability-related information for a specific product, you need to send a request to the Creating a new availability for a product endpoint.
To test the endpoint, open the API reference below or check the example of a curl request.
curl -i -X POST \
'https://api.emporix.io/availability/{tenant}/availability/{productId}/{site}' \
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
-H 'Content-Type: application/json' \
-d '{
"stockLevel": 10,
"available": true,
"popularity": 5,
"distributionChannel": "ASSORTMENT",
"metadata": {
"mixins": {
"productCustomAttributes": "https://res.cloudinary.com/saas-ag/raw/upload/schemata/productCustomAttributesMixIn.v29.json"
}
},
"mixins": {
"productCustomAttributes": {
"minOrderQuantity": 2
}
}
}'
Retrieve the availability information of a product
To check if a product's availability was added successfully, you need to send a request to the Retrieving a product's availability endpoint with the product's ID in the request body.
You can also retrieve availability information for multiple products at once by sending a request to the Retrieving product availabilities for a site endpoint.
To test the endpoint, open the API reference below or check the example of a curl request.
curl -i -X GET \
'https://api.emporix.io/availability/{tenant}/availability/{productId}/{site}' \
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>'
How to calculate a product bundle's stock level
The Availability Service makes it possible to automatically calculate the stock level of a product bundle. The value is always equal to the lowest stock level of the bundled products.
For a product bundle's availability to be calculated, all products in the bundle need to have their availability and stock levels specified. Otherwise, the bundle will be treated as unavailable.
Before you start
Make sure the following requirements are fulfilled:
You have already created all products that make up the bundle.
For instructions, check out How to add your first product.
You have already specified stock levels for all products that make up the bundle.
For instructions, check out How to specify availability, popularity, or stock level for a product.
You have already created a product bundle.
For instructions, check out How to create a bundle of personalized products.
Retrieve the product bundle's availability information
To find out what the stock level of a product bundle is, you need to send a request to the Retrieving a product's availability endpoint with the product bundle's ID in the path.
To test the endpoint, open the API reference below or check the example of a curl request.
curl -i -X GET \
'https://api.emporix.io/availability/{tenant}/availability/{productId}/{site}' \
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>'
The response includes both the availability information of the bundle as a whole, as well as the bundled products.
Last updated
Was this helpful?