I work with an ERP that generates products to be integrated into VTEX, using an ORACLE database. I use auto-numbering for the product ID, always starting from the last number and adding + 1.
I started receiving complaints from VTEX users that, when creating a KIT (a new product) in the VTEX portal (admin), it is generating IDs in the same number range as the ERP. As a result, when a product is pushed to VTEX, it ends up overwriting what was already created.
My question:
Is it possible in VTEX (admin) to define a numeric range so that the numbers donât overlap?
If not, can I retrieve the last ID generated by VTEX so I donât create a duplicate sequence?
The only solution would be for you, instead of doing this:
âI do an auto-numbering on the product ID always starting from the last number adding + 1.ă
Perform a search in VTEX fetching the last included product and add 1 to its ID.
https://{{accountName}}.myvtex.com/api/catalog_system/pvt/products/GetProductAndSkuIds?_from=1&_to=1
It will return this:
{
"data": {
"4199": [
3304423
]
},
"range": {
"total": 1562619,
"from": 1,
"to": 1
}
}
With the informed range.total, you do:
https://{{accountName}}.myvtex.com/api/catalog_system/pvt/products/GetProductAndSkuIds?_from=1562619&_to=1562619
It will return this:
{
"data": {
"4882304": [
3969417
]
},
"range": {
"total": 1562619,
"from": 1562619,
"to": 1562619
}
}
Then you use the number 4882304 +1 as the productId.