mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Hide mouser parts with an invalid product ID to avoid the issue described in #616
This commit is contained in:
parent
32a72bfd23
commit
f6e955b487
1 changed files with 7 additions and 1 deletions
|
@ -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'])) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue