Hide mouser parts with an invalid product ID to avoid the issue described in #616

This commit is contained in:
Jan Böhmer 2024-06-22 23:37:50 +02:00
parent 32a72bfd23
commit f6e955b487

View file

@ -177,7 +177,7 @@ class MouserProvider implements InfoProviderInterface
}
if (count($tmp) > 1) {
throw new \RuntimeException('Multiple parts found with ID '.$id);
throw new \RuntimeException('Multiple parts found with ID '.$id . ' ('.count($tmp).' found). This is basically a bug in Mousers API response. See issue #616.');
}
return $tmp[0];
@ -211,6 +211,12 @@ class MouserProvider implements InfoProviderInterface
$result = [];
foreach ($products as $product) {
//Check if we have a valid product number. We assume that a product number, must have at least 4 characters
//Otherwise filter it out
if (strlen($product['MouserPartNumber']) < 4) {
continue;
}
//Check if we have a mass field available
$mass = null;
if (isset($product['UnitWeightKg']['UnitWeight'])) {