change SPN fallback to be in resolvePartFromLCSC() using PC code for lookup

This commit is contained in:
swdee 2026-03-15 12:07:15 +13:00
parent e11c73aa6d
commit c4fa30851a

View file

@ -142,8 +142,7 @@ final readonly class BarcodeScanResultHandler
} }
if ($barcodeScan instanceof LCSCBarcodeScanResult) { if ($barcodeScan instanceof LCSCBarcodeScanResult) {
return $this->resolvePartFromLCSC($barcodeScan) return $this->resolvePartFromLCSC($barcodeScan);
?? $this->em->getRepository(Part::class)->getPartBySPN($barcodeScan->mpn);
} }
if ($barcodeScan instanceof AmazonBarcodeScanResult) { if ($barcodeScan instanceof AmazonBarcodeScanResult) {
@ -219,6 +218,7 @@ final readonly class BarcodeScanResultHandler
* Strategy: * Strategy:
* 1) Try providerReference.provider_id == pc (LCSC "Cxxxxxx") if you store it there * 1) Try providerReference.provider_id == pc (LCSC "Cxxxxxx") if you store it there
* Returns first match (consistent with EIGP114 logic) * Returns first match (consistent with EIGP114 logic)
* 2) Fallback to search across supplier part number (SPN)
*/ */
private function resolvePartFromLCSC(LCSCBarcodeScanResult $barcodeScan): ?Part private function resolvePartFromLCSC(LCSCBarcodeScanResult $barcodeScan): ?Part
{ {
@ -231,8 +231,8 @@ final readonly class BarcodeScanResultHandler
} }
} }
// part does not exist in DB // fallback to search by SPN
return null; return $this->em->getRepository(Part::class)->getPartBySPN($pc);
} }