This commit is contained in:
seb
2026-10-04 16:22:23 +02:00
parent 54398d90f2
commit 9a1c19cf60
2 changed files with 18 additions and 1 deletions

View File

@@ -27,7 +27,8 @@ export default function setByArticleSku(provider) {
/**
* Replaces all properties for an article by its SKU.
* Enforces exclusive flag on property names.
* Enforces exclusive flag on property names. An exclusive property that already has a value
* is never overwritten: a different value throws `Exclusive property cannot be overwritten: <name>`.
*
* @param {number} googleAuthId - The id of the Google auth user.
* @param {string} sku - The article SKU.
@@ -79,6 +80,12 @@ export default function setByArticleSku(provider) {
}
const value = item.value != null ? String(item.value).trim() : '';
if (isExclusive) {
const existing = oldProps.find((p) => p.propertyId === propertyId);
if (existing && existing.value !== '' && existing.value !== value) {
throw new Error(`Exclusive property cannot be overwritten: ${prop.name}`);
}
}
const sort = item.sort != null && Number.isInteger(item.sort) ? item.sort : i;
validated.push({
propertyId,