PRODUCT - Batch Update Ref. via CSV

Hi Everyone.

I am running Dolibarr version 17.0.2 on Windows.

Around August I imported around 5000 products.

On the “Ref.” field, I referenced my products following a consistent format that looks like:

xxxx yy zz

xxxx = product code

yy = colour

zz = size

After a few months of using Dolibarr, I noticed that when I modify a product through the browser and saving it, it adds “_” in my Product “Ref.” field which makes my “Ref.” inconsistent.

I figured I should change how I should reference my products to play nicer with the system and decided to go with the following format:


Basically replacing the spaces with “-”.

I created a .CSV file with the above modifications which took roughly 10 mins. However, when I run Product Import simulation, I noticed that it is inserting new products not updating.

Is there a way to update the Product “Ref.” field via importing a .CSV file?

I think it is inserting new products because when you import the .CSV file the only available “Key (column) to use for updating existing data” is the “Ref.” column.

Other programs I have used allow me to update the equivalent of Dolibarr’s “Ref.” column without inserting because I was able to use “Technical ID” as Key (Column). However, I do not see this option in Dolibarr.

I am sure that it is definitely possible to do something like this using the API - updating existing products.

How can I use the API? I am not familiar.

I only know how to update via uploading a .CSV.

Is there a tutorial for API method?

You would need to program something, or find someone who can program it for you.

You can access the API using this url under your dolibarr installation /api/index.php/explorer/#/

it requires that you have enabled the API, and that your webserver has not prohibited access to the API - which it should do unless coming from the right address.

Basically using the API someone would get all products/services - or chunks there off, and then update each product/service one by one.

You could probably export the CSV and then cut it down to 2 columns: ID and the ref you want to have it changed to, then it is basically for each line in that CSV send a short json to the API with ID and the u

I will take a look at the API later.

I am not very familiar with programming and terms -_-… but I can follow directions.

Need to see the stuff infront of me and piece it together very slowly.

Alright so I kind of read into this and it seems above my level…

But what I am thinking is I will use my current system as is.

At the same time I will create another instance of Dolibarr with my backup to play around with.

I don’t think I can learn about coding or getting this done in a day as originally intended…

If you need help with a small Programm or importer, Just give me a note. I built a lot of importers to even import directly from exel files via API. Because the CSV importer is not enough for my tasks. Even just modify your ref would be no problem via API.


1 Like