diff --git a/src/Services/ImportExportSystem/PartKeeprImporter/MySQLDumpXMLConverter.php b/src/Services/ImportExportSystem/PartKeeprImporter/MySQLDumpXMLConverter.php index 9d583d2a..4ff9c189 100644 --- a/src/Services/ImportExportSystem/PartKeeprImporter/MySQLDumpXMLConverter.php +++ b/src/Services/ImportExportSystem/PartKeeprImporter/MySQLDumpXMLConverter.php @@ -69,7 +69,10 @@ class MySQLDumpXMLConverter //Iterate over all nodes and convert them to arrays foreach ($tables as $table) { - $table_data[$table->getAttribute('name')] = $this->convertTableToArray($table); + //Normalize the table name to lowercase. On Linux filesystems the tables sometimes contain uppercase letters + //However we expect the table names to be lowercase in the further steps + $table_name = strtolower($table->getAttribute('name')); + $table_data[$table_name] = $this->convertTableToArray($table); } return $table_data; diff --git a/src/Services/ImportExportSystem/PartKeeprImporter/PKPartImporter.php b/src/Services/ImportExportSystem/PartKeeprImporter/PKPartImporter.php index 5065d04c..a0594899 100644 --- a/src/Services/ImportExportSystem/PartKeeprImporter/PKPartImporter.php +++ b/src/Services/ImportExportSystem/PartKeeprImporter/PKPartImporter.php @@ -168,11 +168,21 @@ class PKPartImporter $entity->setName($name); $entity->setValueText($partparameter['stringValue'] ?? ''); - $entity->setUnit($this->getUnitSymbol($data, (int) $partparameter['unit_id'])); + if ($partparameter['unit_id'] === null) { + $entity->setUnit($this->getUnitSymbol($data, (int)$partparameter['unit_id'])); + } else { + $entity->setUnit(""); + } - $entity->setValueMin($partparameter['normalizedMinValue'] ?? null); - $entity->setValueTypical($partparameter['normalizedValue'] ?? null); - $entity->setValueMax($partparameter['normalizedMaxValue'] ?? null); + if ($partparameter['normalizedMinValue'] !== null) { + $entity->setValueMin((float) $partparameter['normalizedMinValue']); + } + if ($partparameter['normalizedValue'] !== null) { + $entity->setValueTypical((float) $partparameter['normalizedValue']); + } + if ($partparameter['normalizedMaxValue'] !== null) { + $entity->setValueMax((float) $partparameter['normalizedMaxValue']); + } $part = $this->em->find(Part::class, (int) $partparameter['part_id']); if (!$part) { @@ -226,6 +236,7 @@ class PKPartImporter $orderdetail->setSupplier($supplier); $orderdetail->setSupplierpartnr($spn); $part->addOrderdetail($orderdetail); + $this->em->persist($orderdetail); } //Add the price information to the orderdetail @@ -236,10 +247,13 @@ class PKPartImporter $price_per_item = BigDecimal::of($partdistributor['price']); $pricedetail->setPrice($price_per_item->multipliedBy($partdistributor['packagingUnit'])); $pricedetail->setPriceRelatedQuantity($partdistributor['packagingUnit'] ?? 1); + + $this->em->persist($pricedetail); } - //We have to flush the changes in every loop, so the find function can find newly created entities $this->em->flush(); + //Clear the entity manager to improve performance + $this->em->clear(); } }