From beea572c47df1ed65d7007ace6b7fdce2b81acfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Aristovnik?= <125830696+barisgit@users.noreply.github.com> Date: Sun, 6 Jul 2025 13:12:04 +0200 Subject: [PATCH] Add supplier information to KiCad part exports (#955) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add supplier information to KiCad part exports - Include supplier name and part numbers from order details in KiCad exports - Handle multiple suppliers with sequential numbering (Supplier 2, Supplier 3, etc.) - Include both active and obsolete order details for comprehensive supplier info - Add null checks to prevent errors when supplier or part number is missing * Add SPN suffix to field name --------- Co-authored-by: Jan Böhmer --- src/Services/EDA/KiCadHelper.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Services/EDA/KiCadHelper.php b/src/Services/EDA/KiCadHelper.php index d4cbab34..74499d3a 100644 --- a/src/Services/EDA/KiCadHelper.php +++ b/src/Services/EDA/KiCadHelper.php @@ -237,6 +237,30 @@ class KiCadHelper $result["fields"]["Part-DB IPN"] = $this->createField($part->getIpn()); } + // Add supplier information from orderdetails (include obsolete orderdetails) + if ($part->getOrderdetails(false)->count() > 0) { + $supplierCounts = []; + + foreach ($part->getOrderdetails(false) as $orderdetail) { + if ($orderdetail->getSupplier() !== null && $orderdetail->getSupplierPartNr() !== '') { + $supplierName = $orderdetail->getSupplier()->getName(); + + $supplierName .= " SPN"; // Append "SPN" to the supplier name to indicate Supplier Part Number + + if (!isset($supplierCounts[$supplierName])) { + $supplierCounts[$supplierName] = 0; + } + $supplierCounts[$supplierName]++; + + // Create field name with sequential number if more than one from same supplier (e.g. "Mouser", "Mouser 2", etc.) + $fieldName = $supplierCounts[$supplierName] > 1 + ? $supplierName . ' ' . $supplierCounts[$supplierName] + : $supplierName; + + $result["fields"][$fieldName] = $this->createField($orderdetail->getSupplierPartNr()); + } + } + } return $result; }