Importing customers automatically

This page describes an example of development used to make imports in Dolibarr by coding. If you are looking for other methods, see page Mass imports.

= Data file =

First you must create your data file and make sure it meets a specific structure:

This file should contain the following fields and must be separated by tabs. The easiest way is to work with excel and then save your document as a tab-delimited text file.

Column1: code_client

Column2: company name

Column3: supplement company name

Column 4: Address Line 1

Column 5: Address Line 2

Colonne6: Address Line 3

Colonne7: Zip Code

Colonne8: City

As you can see the address must be standardized (2 lines for name and 3 lines for the address + ZIP + City). During the import process the 3 address lines will be entered in the single "address" field of Dolibarr with a carriage return after each line. The same will applied for the company name and the company supplement name that will populate the single field "name" of Dolibarr with automatic carriage return.

Colonne9: telephone

Colonne10: fax

Colonne11: email

Colonne12: customer (1 per customer, prospect 2, 0 otherwise)

Colonne13: Provider (1 for supplier or 0 if not vendor)

Colonne14: legal form (See table values llx_c_forme_juridique to feed that column. You can leave this column blank)

Colonne15: type of business (See table values llx_c_typent to feed that column. You can leave this column blank)

Colonne16: Country code (See table values llx_c_pays to feed that column. You can leave this column blank)

Colonne17: url (url of the websites of companies. You can leave this column blank)

Do not add column's header in your file.

Once your columns are filled in, save your file in your data directory under the name societe.txt

= Import script file =

Copy/paste the content below in a new file and save as "import_client.php" under the directory /scripts

Edit the content of this file (the data to modify are in bold italics:

access to the database

path to data according to your tree

All you have to do is open this file with your browser and your data file will be imported.

Hoping it will help some people.