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'],
|
||||||
|
@ -221,13 +231,14 @@ class MouserProvider implements InfoProviderInterface
|
||||||
preview_image_url: $product['ImagePath'],
|
preview_image_url: $product['ImagePath'],
|
||||||
manufacturing_status: $this->releaseStatusCodeToManufacturingStatus(
|
manufacturing_status: $this->releaseStatusCodeToManufacturingStatus(
|
||||||
$product['LifecycleStatus'] ?? null,
|
$product['LifecycleStatus'] ?? null,
|
||||||
(int) ($product['AvailabilityInStock'] ?? 0)
|
(int) ($product['AvailabilityInStock'] ?? 0)
|
||||||
),
|
),
|
||||||
provider_url: $product['ProductDetailUrl'],
|
provider_url: $product['ProductDetailUrl'],
|
||||||
datasheets: $this->parseDataSheets($product['DataSheetUrl'] ?? null,
|
datasheets: $this->parseDataSheets($product['DataSheetUrl'] ?? null,
|
||||||
$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