Skip to content

Commit c60b406

Browse files
committed
Fixed partkeepr import with databases that do not feature custom states
1 parent b1bf70c commit c60b406

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Services/ImportExportSystem/PartKeeprImporter/PKDatastructureImporter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function importPartUnits(array $data): int
152152
public function importPartCustomStates(array $data): int
153153
{
154154
if (!isset($data['partcustomstate'])) {
155-
throw new \RuntimeException('$data must contain a "partcustomstate" key!');
155+
return 0; //Not all PartKeepr installations have custom states
156156
}
157157

158158
$partCustomStateData = $data['partcustomstate'];

src/Services/ImportExportSystem/PartKeeprImporter/PKPartImporter.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ public function importParts(array $data): int
9191
$this->setAssociationField($entity, 'partUnit', MeasurementUnit::class, $part['partUnit_id']);
9292
}
9393

94-
$this->setAssociationField($entity, 'partCustomState', MeasurementUnit::class, $part['partCustomState_id']);
94+
if (isset($part['partCustomState_id'])) {
95+
$this->setAssociationField($entity, 'partCustomState', MeasurementUnit::class,
96+
$part['partCustomState_id']);
97+
}
9598

9699
//Create a part lot to store the stock level and location
97100
$lot = new PartLot();

0 commit comments

Comments
 (0)