Skip to content
Back to Articles

PrestaShop → Google Sheets: product export with Webservice and Apps Script

Live catalogue reports & lightweight data workflows
JAVASCRIPT
const url = shopUrl +
  '/api/products';

const res = UrlFetchApp.fetch(url, {
  headers: {
    Authorization: 'Basic ' + token
  }
});
Automation
Intermediate
PrestaHacks 2 min read

A Google Sheet can be much more than a manual export.

With PrestaShop Webservice and Apps Script you can build a repeatable catalogue report without downloading a CSV every time.

The workflow

TEXT
PRESTASHOP
    ↓
WEBSERVICE API
    ↓
APPS SCRIPT
    ↓
NORMALIZE
    ↓
GOOGLE SHEETS

1. Start read-only

A reporting workflow does not need write permissions.

Tip

Give the API key only the permissions the integration actually needs.

2. Request specific fields

TEXT
/api/products?display=[id,reference,price,active]&output_format=JSON

3. Apps Script configuration

JS
const CONFIG = {
  baseUrl: 'https://shop.example',
  apiKey: 'YOUR_WEBSERVICE_KEY',
  batchSize: 100
};

4. HTTP request

JS
function fetchProducts() {
  const url =
    CONFIG.baseUrl +
    '/api/products' +
    '?display=[id,reference,price,active]' +
    '&output_format=JSON' +
    '&limit=0,' + CONFIG.batchSize;

  const auth = Utilities.base64Encode(CONFIG.apiKey + ':');

  const response = UrlFetchApp.fetch(url, {
    method: 'get',
    headers: { Authorization: 'Basic ' + auth },
    muteHttpExceptions: true
  });

  if (response.getResponseCode() !== 200) {
    throw new Error('PrestaShop HTTP ' + response.getResponseCode());
  }

  return JSON.parse(response.getContentText());
}

5. Normalize first

JS
function productsToRows(products) {
  return products.map(product => [
    product.id,
    product.reference,
    product.price,
    product.active
  ]);
}

6. Write in one operation

Build a two-dimensional array and write it with one setValues() call instead of cell-by-cell updates.

7. Identifier strategy

For internal reporting, id_product is convenient. For ERP or supplier integrations, reference / SKU is usually the external business identifier.

8. Products are not stock

A stock report also needs /api/stock_availables, joined through id_product and id_product_attribute.

9. Decide the row model

Before coding, decide whether you want one row per product or one row per combination.

10. Sync metadata

Keep Last sync, HTTP status, Rows imported and Duration. A Sheet is excellent for reporting, review, mappings, manual overrides and lightweight automations; it does not need to become your primary database.

What to do next

Evolve the read-only report into a supplier-feed transformation pipeline, keeping raw input separate from mapped output. For larger catalogues, apply Webservice pagination before scheduling repeated syncs.

STAY TUNED

Get practical PrestaShop hacks in your inbox.

INACTIVE