mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-03 06:54:34 +02:00
Use full path for categories returned by Octopart
This commit is contained in:
parent
5b1ad541a8
commit
ffe76f9d2e
1 changed files with 14 additions and 2 deletions
|
@ -58,8 +58,10 @@ class OctopartProvider implements InfoProviderInterface
|
||||||
}
|
}
|
||||||
shortDescription
|
shortDescription
|
||||||
category {
|
category {
|
||||||
|
ancestors {
|
||||||
|
name
|
||||||
|
}
|
||||||
name
|
name
|
||||||
path
|
|
||||||
}
|
}
|
||||||
bestImage {
|
bestImage {
|
||||||
url
|
url
|
||||||
|
@ -290,12 +292,22 @@ class OctopartProvider implements InfoProviderInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Built the category full path
|
||||||
|
$category = null;
|
||||||
|
if ($part['category']['name'] !== null) {
|
||||||
|
$category = implode(' -> ', array_map(fn($c) => $c['name'], $part['category']['ancestors'] ?? []));
|
||||||
|
if (!empty($category)) {
|
||||||
|
$category .= ' -> ';
|
||||||
|
}
|
||||||
|
$category .= $part['category']['name'];
|
||||||
|
}
|
||||||
|
|
||||||
return new PartDetailDTO(
|
return new PartDetailDTO(
|
||||||
provider_key: $this->getProviderKey(),
|
provider_key: $this->getProviderKey(),
|
||||||
provider_id: $part['id'],
|
provider_id: $part['id'],
|
||||||
name: $part['mpn'],
|
name: $part['mpn'],
|
||||||
description: $part['shortDescription'] ?? null,
|
description: $part['shortDescription'] ?? null,
|
||||||
category: $part['category']['name'] ?? null,
|
category: $category ,
|
||||||
manufacturer: $part['manufacturer']['name'] ?? null,
|
manufacturer: $part['manufacturer']['name'] ?? null,
|
||||||
mpn: $part['mpn'],
|
mpn: $part['mpn'],
|
||||||
preview_image_url: $part['bestImage']['url'] ?? null,
|
preview_image_url: $part['bestImage']['url'] ?? null,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue