Skip to main content

Products Bulk

Use the REST API to interact with the products in the application.

You should take into account when making your request
info

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?
info

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.

Clear cache

Permissions
info

The user must be assigned the permission to: 'bulk' => 'icommerce::products.bulk resource',

Clear cache

How to check the response for each chunk that has been executed?
info

To view the response of each chunk, you must create a webhook. Visit this section

Create Products

Use this endpoint to general process.

POST/api/icommerce/v3/products/bulk
{
"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
}
]
}
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
POST/api/icommerce/v3/products/bulk
{
"items":[
{
"id":9999,
"category_id": "2"
}
]
}
Response
{
"data": {
"bulkId": "bulk_675c53516d618",
"chunks": 1,
"errors": 0,
"msjs": []
}
}

Bulk Response

Description of the endpoint response:

bulkIdGeneral process identifier.
chunksNumber of chunks to be executed.
errorsNumber of errors if any occurred.
msjsError 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
}
]
}
]
info
  • 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: Clear cache
  • Create a hook: Clear cache

Information with which the hook must be created:

Method HTTPselect "POST"
URLAdd URL where the information will be sent.
CategorySelect a category.
TypeSelect "Event".
EntitySelect "Product".
EventSelect "Bulk".

Response

Response Body Example:

    {
"chunkId": "bulk_675c53516d618_0",
"partition": 0,
"totalItems": 1,
"completed": 1,
"itemsCompleted": [....],
"errors": 0,
"msjs": []
}
chunkIdchunk identifier | It is composed of the bulkId and partition.
partitionNumber of the partition that was executed. (starts at 0)
totalItemsTotal items that were attempted to be processed
completedTotal items successfully processed
itemsCompletedArray with information about the items created or updated
errorsNumber of errors if any occurred.
msjsError 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.