PrestaShop → Google Sheets: product export με Webservice και Apps Script
const url = shopUrl +
'/api/products';
const res = UrlFetchApp.fetch(url, {
headers: {
Authorization: 'Basic ' + token
}
});
Ένα Google Sheet μπορεί να γίνει πολύ περισσότερο από ένα manual export.
Με το PrestaShop Webservice και Apps Script μπορείς να δημιουργήσεις ένα repeatable catalogue report χωρίς να κατεβάζεις CSV κάθε φορά.
Το workflow
PRESTASHOP
↓
WEBSERVICE API
↓
APPS SCRIPT
↓
NORMALIZE
↓
GOOGLE SHEETS1. Ξεκίνα read-only
Για reporting workflow το API key δεν χρειάζεται write permissions.
Tip
Δώσε μόνο τα permissions που χρειάζεται πραγματικά το integration.
2. Ζήτησε συγκεκριμένα fields
/api/products?display=[id,reference,price,active]&output_format=JSON3. Apps Script configuration
const CONFIG = {
baseUrl: 'https://shop.example',
apiKey: 'YOUR_WEBSERVICE_KEY',
batchSize: 100
};4. HTTP request
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 πρώτα
function productsToRows(products) {
return products.map(product => [
product.id,
product.reference,
product.price,
product.active
]);
}6. Write σε μία operation
function writeProducts(rows) {
const sheet =
SpreadsheetApp.getActive()
.getSheetByName('Products');
sheet.clearContents();
const values = [
['ID', 'Reference', 'Price', 'Active'],
...rows
];
sheet
.getRange(1, 1, values.length, values[0].length)
.setValues(values);
}7. Identifier strategy
Για internal reporting:
id_productΓια ERP / supplier integrations:
reference / SKU8. Products ≠ stock
Για stock report χρειάζεσαι και:
/api/stock_availablesμε join σε:
id_product
id_product_attribute9. Products με combinations
Πριν το coding αποφάσισε:
ONE ROW PER PRODUCTή:
ONE ROW PER COMBINATION10. Sync metadata
Κράτα:
Last sync
HTTP status
Rows imported
DurationΠού είναι ιδανικό το Sheet
- reporting,
- review,
- mappings,
- manual overrides,
- lightweight automations.
Δεν χρειάζεται να γίνει η primary database σου.
[SCREENSHOT PLACEHOLDER 01]
Google Sheet με normalized Products tab.
[SCREENSHOT PLACEHOLDER 02]
Apps Script με
UrlFetchApp.fetch().
Καλό πρώτο automation
PrestaShop
↓
Daily read-only sync
↓
Google Sheet
↓
Catalogue reviewΠριν γράψεις data πίσω στο shop, φτιάξε πρώτα ένα αξιόπιστο read/reporting pipeline.
Τι να κάνεις μετά
Εξέλιξε το read-only report σε supplier-feed transformation pipeline, κρατώντας χωριστά το raw input και το mapped output. Για μεγαλύτερα catalogues, εφάρμοσε Webservice pagination πριν προγραμματίσεις επαναλαμβανόμενα syncs.