From c4fa30851a9a64030f17b77db379c9077834dbfb Mon Sep 17 00:00:00 2001 From: swdee Date: Sun, 15 Mar 2026 12:07:15 +1300 Subject: [PATCH] change SPN fallback to be in resolvePartFromLCSC() using PC code for lookup --- .../BarcodeScanner/BarcodeScanResultHandler.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Services/LabelSystem/BarcodeScanner/BarcodeScanResultHandler.php b/src/Services/LabelSystem/BarcodeScanner/BarcodeScanResultHandler.php index 3cf01249..1927edb9 100644 --- a/src/Services/LabelSystem/BarcodeScanner/BarcodeScanResultHandler.php +++ b/src/Services/LabelSystem/BarcodeScanner/BarcodeScanResultHandler.php @@ -142,8 +142,7 @@ final readonly class BarcodeScanResultHandler } if ($barcodeScan instanceof LCSCBarcodeScanResult) { - return $this->resolvePartFromLCSC($barcodeScan) - ?? $this->em->getRepository(Part::class)->getPartBySPN($barcodeScan->mpn); + return $this->resolvePartFromLCSC($barcodeScan); } if ($barcodeScan instanceof AmazonBarcodeScanResult) { @@ -219,6 +218,7 @@ final readonly class BarcodeScanResultHandler * Strategy: * 1) Try providerReference.provider_id == pc (LCSC "Cxxxxxx") if you store it there * Returns first match (consistent with EIGP114 logic) + * 2) Fallback to search across supplier part number (SPN) */ private function resolvePartFromLCSC(LCSCBarcodeScanResult $barcodeScan): ?Part { @@ -231,8 +231,8 @@ final readonly class BarcodeScanResultHandler } } - // part does not exist in DB - return null; + // fallback to search by SPN + return $this->em->getRepository(Part::class)->getPartBySPN($pc); }