mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-03 06:54:34 +02:00
Retrieve the part mass from mouser API if available
This commit is contained in:
parent
1e6065f732
commit
c989be2719
1 changed files with 12 additions and 1 deletions
|
@ -210,6 +210,16 @@ class MouserProvider implements InfoProviderInterface
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($products as $product) {
|
foreach ($products as $product) {
|
||||||
|
|
||||||
|
//Check if we have a mass field available
|
||||||
|
$mass = null;
|
||||||
|
if (isset($product['UnitWeightKg']['UnitWeight'])) {
|
||||||
|
$mass = (float) $product['UnitWeightKg']['UnitWeight'];
|
||||||
|
//The mass is given in kg, we want it in g
|
||||||
|
$mass *= 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$result[] = new PartDetailDTO(
|
$result[] = new PartDetailDTO(
|
||||||
provider_key: $this->getProviderKey(),
|
provider_key: $this->getProviderKey(),
|
||||||
provider_id: $product['MouserPartNumber'],
|
provider_id: $product['MouserPartNumber'],
|
||||||
|
@ -228,6 +238,7 @@ class MouserProvider implements InfoProviderInterface
|
||||||
$product['MouserPartNumber'] ?? null),
|
$product['MouserPartNumber'] ?? null),
|
||||||
vendor_infos: $this->pricingToDTOs($product['PriceBreaks'] ?? [], $product['MouserPartNumber'],
|
vendor_infos: $this->pricingToDTOs($product['PriceBreaks'] ?? [], $product['MouserPartNumber'],
|
||||||
$product['ProductDetailUrl']),
|
$product['ProductDetailUrl']),
|
||||||
|
mass: $mass,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue