From c60b406157a4cfcedca9e114216a2ab9a45a5a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 7 Dec 2025 20:21:19 +0100 Subject: [PATCH] Fixed partkeepr import with databases that do not feature custom states --- .../PartKeeprImporter/PKDatastructureImporter.php | 2 +- .../ImportExportSystem/PartKeeprImporter/PKPartImporter.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Services/ImportExportSystem/PartKeeprImporter/PKDatastructureImporter.php b/src/Services/ImportExportSystem/PartKeeprImporter/PKDatastructureImporter.php index 9e674f05..ec23d34b 100644 --- a/src/Services/ImportExportSystem/PartKeeprImporter/PKDatastructureImporter.php +++ b/src/Services/ImportExportSystem/PartKeeprImporter/PKDatastructureImporter.php @@ -152,7 +152,7 @@ class PKDatastructureImporter public function importPartCustomStates(array $data): int { if (!isset($data['partcustomstate'])) { - throw new \RuntimeException('$data must contain a "partcustomstate" key!'); + return 0; //Not all PartKeepr installations have custom states } $partCustomStateData = $data['partcustomstate']; diff --git a/src/Services/ImportExportSystem/PartKeeprImporter/PKPartImporter.php b/src/Services/ImportExportSystem/PartKeeprImporter/PKPartImporter.php index ab06a134..cab5a49b 100644 --- a/src/Services/ImportExportSystem/PartKeeprImporter/PKPartImporter.php +++ b/src/Services/ImportExportSystem/PartKeeprImporter/PKPartImporter.php @@ -91,7 +91,10 @@ class PKPartImporter $this->setAssociationField($entity, 'partUnit', MeasurementUnit::class, $part['partUnit_id']); } - $this->setAssociationField($entity, 'partCustomState', MeasurementUnit::class, $part['partCustomState_id']); + if (isset($part['partCustomState_id'])) { + $this->setAssociationField($entity, 'partCustomState', MeasurementUnit::class, + $part['partCustomState_id']); + } //Create a part lot to store the stock level and location $lot = new PartLot();