From a27c2ca3e5cf473d7534001b575aeb7ab496eb78 Mon Sep 17 00:00:00 2001 From: objec Date: Thu, 5 Mar 2026 16:41:45 +0400 Subject: [PATCH] Items CSV Import Attribute Delete - Validation checks bypass magic word cells. - Delete the attribute link for an item if the CSV contains `_DELETE_` Signed-off-by: objec --- app/Controllers/Items.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/Controllers/Items.php b/app/Controllers/Items.php index 22e8f4c44..1f9bdc6cf 100644 --- a/app/Controllers/Items.php +++ b/app/Controllers/Items.php @@ -1158,7 +1158,11 @@ class Items extends Secure_Controller $definition_type = $attribute_data[$definition_name]['definition_type']; $attribute_value = $row["attribute_$definition_name"]; - switch ($definition_type) { + if (strcasecmp($attributeValue, '_DELETE_') === 0) { + continue; + } + + switch ($definitionType) { case DROPDOWN: $dropdown_values = $attribute_data[$definition_name]['dropdown_values']; $dropdown_values[] = ''; @@ -1195,11 +1199,18 @@ class Items extends Secure_Controller * @param array $definitions * @return bool */ - private function save_attribute_data(array $row, array $item_data, array $definitions): bool + private function saveAttributeData(array $row, array $itemData, array $definitions): bool { foreach ($definitions as $definition) { $attribute_name = $definition['definition_name']; $attribute_value = $row["attribute_$attribute_name"]; + $attributeName = $definition['definition_name']; + $attributeValue = $row["attribute_$attributeName"]; + + if (isset($attributeValue) && strcasecmp($attributeValue, '_DELETE_') === 0) { + $this->attribute->deleteAttributeLinks($itemData['item_id'], $definition['definition_id']); + continue; + } // Create attribute value if (!empty($attribute_value) || $attribute_value === '0') {