Products Bulk
Use the REST API to interact with the products in the application.
You should take into account when making your request
Remember that for some requests, you need to send the authentication token.
Header Parameters
{
"Authorization": "Bearer ...token..."
}
And the query parameters are as follows:
Query Parameters
{
"setting": {
"timezone": "America/Bogota",
"fromAdmin": true,
"appMode": "iadmin",
"authProvider": "local",
"locale": "en"
}
}
Do you want to see the changes made through the API?
After using the API to access products, it's important to update the cache to see the changes.
How to do it:
- Go to the upper-right corner and select the dropdown menu with your username.
- Click on 'Settings.'
- In the 'Actions' section, look for the 'Clear Cache' option.
- Click on 'Clear Cache' to update the information and view the updated products.
Permissions
The user must be assigned the permission to: 'bulk' => 'icommerce::products.bulk resource',
How to check the response for each chunk that has been executed?
To view the response of each chunk, you must create a webhook. Visit this section
Create Products
Use this endpoint to general process.
- Minimum
- Rest
{
"items":[
{
"category_id": "1", // This Id is the identification of the categories
"en": { // This depends on the server's language
"name": "Test",
"slug": "test",
"summary": "Summary",
"description": "Description" // You can use HTML for this field
}
]
}
{
"items":[
{
"category_id": "1", // This Id is the identification of the categories
"en": { // This depends on the server's language
"name": "Test",
"slug": "test",
"summary": "Summary",
"description": "Description" // You can use HTML for this field
},
"quantity": 9999,
"price": "20000",
"productWarehouses":[
{
"warehouse_id": 2,
"quantity": 15
}
]
}
]
}
Response
{
"data": {
"bulkId": "bulk_675c53516d618",
"chunks": 1,
"errors": 0,
"msjs": []
}
}
Update Products
- Use the same endpoint
- The difference is that to update you must send the product ID
- Minimum
- Rest
{
"items":[
{
"id":9999,
"category_id": "2"
}
]
}
{
"items":[
{
"id":9999,
"productWarehouses":[
{
"warehouse_id": 2,
"quantity": 15
}
]
}
]
}
Response
{
"data": {
"bulkId": "bulk_675c53516d618",
"chunks": 1,
"errors": 0,
"msjs": []
}
}
Bulk Response
Description of the endpoint response:
bulkId | General process identifier. |
chunks | Number of chunks to be executed. |
errors | Number of errors if any occurred. |
msjs | Error related messages. |
Example [msjs] error data
//All error msjs
"msjs": [
{
"type": "error",
"operation": "create", // Create or Update
"msjs": "{\"es.slug\":[\"There are another register with the same slug-locale.\"]}", //Error for this item
"item": {} // Item data
}
]
Relations
Product Warehouse
- Relation Name: productWarehouses
- You must add in each item where you need the information.
Example: Create a Product with productWarehouses relation
"items":[
{
"en": {
"name":"Producto x",
"slug":"producto-x",
"description": "esta es una prueba",
"summary":"Esto es una prueba",
},
"category_id": 1,
"quantity": 9999,
"price": "20000",
"productWarehouses":[
{
"warehouse_id": 2,
"quantity": 15
}
]
}
]
Example: Update an quantity for a product in a warehouse
"items":[
{
"id": 9999,// Product Id
"productWarehouses":[
{
"warehouse_id": 2,
"quantity": 20 //Update this quantity
}
]
}
]
Product Discount
- Relation Name: discounts
- You must add in each item where you need the information.
Example: Create a Product with discount
"items":[
{
"es": {
"name":"Producto x",
"slug":"producto-x",
"description": "esta es una prueba",
"summary":"Esto es una prueba",
},
"category_id": 1,
"quantity": 9999,
"price": "20000",
"discounts":[
{
"quantity": 5,
"discount": 5,
"date_start": "2024-12-06",
"date_end": "2024-12-10"
}
]
}
]
Example: Update a Product with discount
"items":[
{
"id": 9999,// Product Id
"discounts":[
{
"quantity": 10,
"discount": 5,
"date_start": "2024-12-06",
"date_end": "2024-12-20" //Update this
}
]
}
]
- If the product already had a discount, and a new one is sent. The previous one will be deleted and the new one will be added.
- If the product already had a discount, and another discount is being added and you want to maintain the previous one. Both discounts must be submitted
Webhook
- Every time a chunk process completes (Job), a Post Request will be sent with the result.
- The url must be provided to the support team.
Create
- Go to Iadmin->Menu->Webhook
- Create a Category. Example:
- Create a hook:
Information with which the hook must be created:
Method HTTP | select "POST" |
URL | Add URL where the information will be sent. |
Category | Select a category. |
Type | Select "Event". |
Entity | Select "Product". |
Event | Select "Bulk". |
Response
Response Body Example:
{
"chunkId": "bulk_675c53516d618_0",
"partition": 0,
"totalItems": 1,
"completed": 1,
"itemsCompleted": [....],
"errors": 0,
"msjs": []
}
chunkId | chunk identifier | It is composed of the bulkId and partition. |
partition | Number of the partition that was executed. (starts at 0) |
totalItems | Total items that were attempted to be processed |
completed | Total items successfully processed |
itemsCompleted | Array with information about the items created or updated |
errors | Number of errors if any occurred. |
msjs | Error related messages. |
If you need further assistance or have any questions about how to fill out these fields, please don't hesitate to contact our support team.