Dolibarr ERP/CRM and PrestaShop are two powerful open-source platforms widely used by businesses worldwide. Dolibarr handles ERP, CRM, invoicing, accounting, and stock management. PrestaShop excels in e-commerce. When used together, they provide a robust solution for managing both online sales and internal business operations. However, many integration solutions rely on paid plugins or third-party connectors. This guide shows you how to connect Dolibarr to PrestaShop without using any paid plugins.

Table of Contents

  1. Why Integrate Dolibarr with PrestaShop?

  2. Overview of Integration Methods

  3. Requirements and Preparations

  4. Understanding the PrestaShop Webservice API

  5. Understanding Dolibarr’s REST API

  6. Setting Up the PrestaShop Webservice

  7. Activating and Using Dolibarr’s API

  8. Mapping Data Between PrestaShop and Dolibarr

  9. Writing a Custom Integration Script

  10. Automating the Synchronization Process

  11. Managing Authentication and Security

  12. Handling Common Synchronization Challenges

  13. Testing and Debugging the Integration

  14. Limitations and Workarounds Without Paid Modules

  15. Final Recommendations and Best Practices


1. Why Integrate Dolibarr with PrestaShop?

Integrating Dolibarr with PrestaShop provides several advantages:

  • Automatically import orders from your shop into Dolibarr

  • Sync product stocks between ERP and e-commerce

  • Streamline invoice generation

  • Centralize customer data management

  • Reduce data entry errors and manual work

This level of automation improves efficiency, speeds up order processing, and enhances customer satisfaction.


2. Overview of Integration Methods

There are three primary ways to connect Dolibarr to PrestaShop:

  1. Using a paid module or plugin (e.g., DoliShop or third-party connectors)

  2. Manual data transfer using CSV/XML (low automation)

  3. Custom integration using APIs (focus of this article)

Custom integration using both systems' APIs gives you full control, flexibility, and zero cost.


3. Requirements and Preparations

Before starting the integration process, ensure the following:

  • You have administrative access to both Dolibarr and PrestaShop

  • Your PrestaShop version supports the Webservice API (v1.6+)

  • Your Dolibarr version supports the REST API (v9.0+)

  • You have a server or development environment to run scripts

  • Basic knowledge of PHP or Python for scripting

Prepare by:

  • Backing up both systems

  • Creating API users or keys

  • Listing the fields to sync (e.g., customers, products, orders)


4. Understanding the PrestaShop Webservice API

PrestaShop provides a REST-like Webservice API that allows CRUD (Create, Read, Update, Delete) operations on:

  • Customers

  • Orders

  • Products

  • Carts

  • Categories

You can enable the API from:

PrestaShop > Advanced Parameters > Webservice

Enable the API and generate a key. Assign permissions for the resources you want to use (e.g., orders, products, customers).

Base URL structure:

https://yourshop.com/api/

Use HTTP headers to send the API key with each request.


5. Understanding Dolibarr’s REST API

Dolibarr also offers a REST API, available at:

https://yourdolibarr.com/api/index.php/

You must enable the API by activating the API module in Dolibarr:

  • Home > Setup > Modules > Web Services/API

Generate an API key per user and define their permissions. Dolibarr’s API supports:

  • Third-parties (clients/suppliers)

  • Products

  • Orders and invoices

  • Stocks and warehouses

Make sure to test access using tools like Postman or curl.


6. Setting Up the PrestaShop Webservice

In the PrestaShop admin panel:

  1. Go to Advanced Parameters > Webservice

  2. Click "Add New Webservice Key"

  3. Generate a 32-character key

  4. Assign permissions (GET, POST, PUT, DELETE) for each resource

  5. Save

Test the API by accessing:

curl -X GET https://yourshop.com/api/orders -H "Authorization: YOUR_API_KEY"

A successful response means your API is correctly configured.


7. Activating and Using Dolibarr’s API

  1. Activate the API module

  2. Generate a key from the user profile page

  3. Enable the modules you want to expose via API (Invoices, Orders, Products)

  4. Access the API with the URL:

https://yourdolibarr.com/api/index.php/orders

Use the DOLAPIKEY as a parameter or HTTP header.

Example using curl:

curl -X GET "https://yourdolibarr.com/api/index.php/orders?DOLAPIKEY=yourkey"

8. Mapping Data Between PrestaShop and Dolibarr

Decide what data to sync and how fields match between the two systems:

PrestaShop Field Dolibarr Field
id_customer thirdparty_id
reference ref_client
total_paid total_ttc
products lines
email email

Plan mapping for:

  • Orders

  • Products

  • Customers

  • Inventory

Store mapping logic in your integration script.


9. Writing a Custom Integration Script

Use PHP or Python to pull data from PrestaShop and push to Dolibarr.

Example in PHP:

// Fetch orders from PrestaShop
$prestashop_url = 'https://yourshop.com/api/orders';
$context = stream_context_create(['http' => [
  'header' => "Authorization: Basic YOUR_KEY"
]]);
$response = file_get_contents($prestashop_url, false, $context);
$orders = json_decode($response, true);

// Prepare and send to Dolibarr
foreach ($orders as $order) {
  $data = [
    'ref_client' => $order['reference'],
    'thirdparty_id' => getDolibarrCustomerId($order['id_customer']),
    'lines' => convertProductLines($order['products']),
    'total_ttc' => $order['total_paid']
  ];

  // Send to Dolibarr
  $curl = curl_init('https://yourdolibarr.com/api/index.php/orders?DOLAPIKEY=yourkey');
  curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($curl, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
  $result = curl_exec($curl);
  curl_close($curl);
}

10. Automating the Synchronization Process

To automate the integration:

  • Set up a cron job to run your script periodically

  • Log each run for debugging and auditing

  • Create a status system (e.g., mark synced orders)

Example cron job:

*/15 * * * * /usr/bin/php /path/to/sync-script.php

11. Managing Authentication and Security

  • Use HTTPS to encrypt data in transit

  • Store API keys securely using environment variables or config files outside webroot

  • Restrict IPs or domains allowed to access the APIs

  • Rotate keys periodically

Security is crucial, especially when customer and payment data is being exchanged.


12. Handling Common Synchronization Challenges

You may encounter:

  • Data mismatch (different formats or currencies)

  • Missing fields (incomplete customer info)

  • Rate limits or timeouts

  • API version changes

Implement error handling:

  • Retry logic for failed syncs

  • Validation before data submission

  • Alert system for failed cron runs


13. Testing and Debugging the Integration

Use tools like:

  • Postman: for testing API endpoints

  • Log files: store every request and response

  • Browser console and server logs for debugging

Perform tests with:

  • New orders

  • Updated customer records

  • Inventory updates

Start with manual runs before automating.


14. Limitations and Workarounds Without Paid Modules

Without paid plugins, there are some constraints:

  • No GUI for mapping data

  • No real-time sync unless you build webhooks

  • Limited to what API endpoints offer

Workarounds:

  • Build your own interface for mapping and monitoring

  • Use database triggers if both systems are hosted together

  • Leverage background workers for real-time sync


15. Final Recommendations and Best Practices

Integrating Dolibarr with PrestaShop without paid plugins is entirely possible, but it requires planning and scripting skills. To make it sustainable:

  • Start with small datasets (test customers or one order)

  • Document your mapping and logic

  • Create logs and alerts for monitoring

  • Secure your integration (SSL, authentication, key management)

  • Keep both systems updated to avoid compatibility issues

With time and refinement, your custom integration can be as powerful and flexible as any premium module.