Make the manufacturer field optional on part manufacturer data during Partkeepr import

This should fix issue #333
This commit is contained in:
Jan Böhmer 2023-07-26 22:55:18 +02:00
parent 90fbcb88d8
commit ed6b0057b7

View file

@ -145,7 +145,8 @@ class PKPartImporter
throw new \RuntimeException(sprintf('Could not find part with ID %s', $partmanufacturer['part_id'])); throw new \RuntimeException(sprintf('Could not find part with ID %s', $partmanufacturer['part_id']));
} }
$manufacturer = $this->em->find(Manufacturer::class, (int) $partmanufacturer['manufacturer_id']); $manufacturer = $this->em->find(Manufacturer::class, (int) $partmanufacturer['manufacturer_id']);
if (!$manufacturer instanceof Manufacturer) { //The manufacturer is optional
if (!$manufacturer instanceof Manufacturer && !empty($partmanufacturer['manufacturer_id'])) {
throw new \RuntimeException(sprintf('Could not find manufacturer with ID %s', $partmanufacturer['manufacturer_id'])); throw new \RuntimeException(sprintf('Could not find manufacturer with ID %s', $partmanufacturer['manufacturer_id']));
} }
$part->setManufacturer($manufacturer); $part->setManufacturer($manufacturer);