Files
core-prestashop/methods/updateConfig.js
T
fatequodandCursor 1a6a978a21 Migrate to @orbito/api-lib 2.0.0 for single-company container model.
Remove companyId from handlers, models, cron jobs, and cross-module calls to match the v2 one-module-one-company architecture.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-08 11:21:35 +02:00

25 lines
963 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const { DB, Utils, Log } = require('@orbito/api-lib');
const ShopConfigSchema = require('../src/models/ShopConfig');
module.exports = async function(params, ctx) {
const editableFields = ['apiUrl', 'apiKey', 'shopName', 'versionCode', 'orderStatus'];
const dataToUpdate = {};
for (const field of editableFields) {
if (typeof params[field] !== 'undefined') {
dataToUpdate[field] = params[field];
}
}
// Jeśli podano _id – aktualizuj konkretny rekord
if (params._id) {
const config = await ShopConfigSchema.findOne({ _id: params._id, isRemoved: { $ne: true } });
if (!config) throw new Error('Config not found');
await ShopConfigSchema.update({ _id: config._id }, dataToUpdate);
return await ShopConfigSchema.findOne({ _id: config._id });
}
// Brak _id – twórz nowy rekord
const newConfig = await ShopConfigSchema.create(dataToUpdate);
return newConfig;
}