feat(prestashop): sync catalog base prices in 1.1.12

This commit is contained in:
fatequod
2026-09-21 15:35:21 +02:00
parent 11f1c99e2b
commit aa5297c5d8
8 changed files with 84 additions and 22 deletions
+18 -5
View File
@@ -122,12 +122,17 @@ async function importFromPSOrder(orderId, api, config) {
} catch (_) { /* no image available */ }
try {
Object.assign(p, await resolveProductMetadata(api, psProduct, {
const metadata = await resolveProductMetadata(api, psProduct, {
sourceId: productId,
sku: p.sku,
combination: productCombination,
requiresCombination: combinationId !== '0',
}));
});
if (Object.hasOwn(metadata, 'unitPrice')) {
p.baseUnitPrice = metadata.unitPrice;
delete metadata.unitPrice;
}
Object.assign(p, metadata);
} catch (_) { /* optional product metadata must not block order import */ }
if (psProduct.type == "pack" && psProduct.associations.product_bundle) {
@@ -157,12 +162,17 @@ async function importFromPSOrder(orderId, api, config) {
if (packWeight !== undefined) pData.weight = packWeight;
try {
Object.assign(pData, await resolveProductMetadata(api, psItem, {
const metadata = await resolveProductMetadata(api, psItem, {
sourceId: packProductId,
sku: pData.sku,
combination: packCombination,
requiresCombination: packCombinationId !== '0',
}));
});
if (Object.hasOwn(metadata, 'unitPrice')) {
pData.baseUnitPrice = metadata.unitPrice;
delete metadata.unitPrice;
}
Object.assign(pData, metadata);
} catch (_) { /* optional product metadata must not block order import */ }
try {
@@ -188,7 +198,10 @@ async function importFromPSOrder(orderId, api, config) {
sku: product.sku || '',
name: product.name,
};
for (const field of ['unitPrice', 'tax', 'weight', 'ean', 'coverImageUrl', 'brand', 'warehouseLocation']) {
if (Object.hasOwn(product, 'baseUnitPrice') && product.baseUnitPrice !== undefined) {
upsert.unitPrice = product.baseUnitPrice;
}
for (const field of ['tax', 'weight', 'ean', 'coverImageUrl', 'brand', 'warehouseLocation']) {
if (Object.hasOwn(product, field) && product[field] !== undefined) upsert[field] = product[field];
}
await Core.callModule('core/products', 'upsert', upsert).catch(error => {