mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Use newer version of farnell/element14 api to get the correct links to product pages. Also we can now retrieve a more detailed description, which will be put into the notes field
This commit is contained in:
parent
319b69f6c7
commit
5d3f861728
1 changed files with 8 additions and 11 deletions
|
@ -35,7 +35,7 @@ class Element14Provider implements InfoProviderInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
private const ENDPOINT_URL = 'https://api.element14.com/catalog/products';
|
private const ENDPOINT_URL = 'https://api.element14.com/catalog/products';
|
||||||
private const API_VERSION_NUMBER = '1.2';
|
private const API_VERSION_NUMBER = '1.4';
|
||||||
private const NUMBER_OF_RESULTS = 20;
|
private const NUMBER_OF_RESULTS = 20;
|
||||||
|
|
||||||
public const DISTRIBUTOR_NAME = 'Farnell';
|
public const DISTRIBUTOR_NAME = 'Farnell';
|
||||||
|
@ -83,7 +83,7 @@ class Element14Provider implements InfoProviderInterface
|
||||||
'resultsSettings.responseGroup' => 'large',
|
'resultsSettings.responseGroup' => 'large',
|
||||||
'callInfo.apiKey' => $this->api_key,
|
'callInfo.apiKey' => $this->api_key,
|
||||||
'callInfo.responseDataFormat' => 'json',
|
'callInfo.responseDataFormat' => 'json',
|
||||||
'callInfo.version' => self::API_VERSION_NUMBER,
|
'versionNumber' => self::API_VERSION_NUMBER,
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -107,21 +107,18 @@ class Element14Provider implements InfoProviderInterface
|
||||||
mpn: $product['translatedManufacturerPartNumber'],
|
mpn: $product['translatedManufacturerPartNumber'],
|
||||||
preview_image_url: $this->toImageUrl($product['image'] ?? null),
|
preview_image_url: $this->toImageUrl($product['image'] ?? null),
|
||||||
manufacturing_status: $this->releaseStatusCodeToManufacturingStatus($product['releaseStatusCode'] ?? null),
|
manufacturing_status: $this->releaseStatusCodeToManufacturingStatus($product['releaseStatusCode'] ?? null),
|
||||||
provider_url: $this->generateProductURL($product['sku']),
|
provider_url: $product['productURL'],
|
||||||
|
notes: $product['productOverview']['description'] ?? null,
|
||||||
datasheets: $this->parseDataSheets($product['datasheets'] ?? null),
|
datasheets: $this->parseDataSheets($product['datasheets'] ?? null),
|
||||||
parameters: $this->attributesToParameters($product['attributes'] ?? null),
|
parameters: $this->attributesToParameters($product['attributes'] ?? null),
|
||||||
vendor_infos: $this->pricesToVendorInfo($product['sku'], $product['prices'] ?? [])
|
vendor_infos: $this->pricesToVendorInfo($product['sku'], $product['prices'] ?? [], $product['productURL']),
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generateProductURL($sku): string
|
|
||||||
{
|
|
||||||
return 'https://' . $this->store_id . '/' . $sku;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array|null $datasheets
|
* @param array|null $datasheets
|
||||||
* @return FileDTO[]|null Array of FileDTOs
|
* @return FileDTO[]|null Array of FileDTOs
|
||||||
|
@ -161,7 +158,7 @@ class Element14Provider implements InfoProviderInterface
|
||||||
* @param array $prices
|
* @param array $prices
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function pricesToVendorInfo(string $sku, array $prices): array
|
private function pricesToVendorInfo(string $sku, array $prices, string $product_url): array
|
||||||
{
|
{
|
||||||
$price_dtos = [];
|
$price_dtos = [];
|
||||||
|
|
||||||
|
@ -179,7 +176,7 @@ class Element14Provider implements InfoProviderInterface
|
||||||
distributor_name: self::DISTRIBUTOR_NAME,
|
distributor_name: self::DISTRIBUTOR_NAME,
|
||||||
order_number: $sku,
|
order_number: $sku,
|
||||||
prices: $price_dtos,
|
prices: $price_dtos,
|
||||||
product_url: $this->generateProductURL($sku)
|
product_url: $product_url
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue