From fd76ca12fc67aeb76d46b867c64d69e75896e563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 8 Feb 2026 15:32:35 +0100 Subject: [PATCH] Allow to import GTIN from info providers --- src/Services/InfoProviderSystem/DTOs/PartDetailDTO.php | 2 ++ src/Services/InfoProviderSystem/DTOs/SearchResultDTO.php | 4 ++++ src/Services/InfoProviderSystem/DTOtoEntityConverter.php | 2 ++ .../InfoProviderSystem/Providers/ConradProvider.php | 4 ++++ .../InfoProviderSystem/Providers/ProviderCapabilities.php | 6 ++++++ templates/info_providers/search/part_search.html.twig | 8 +++++++- templates/parts/info/_sidebar.html.twig | 8 ++++++++ translations/messages.en.xlf | 6 ++++++ 8 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/Services/InfoProviderSystem/DTOs/PartDetailDTO.php b/src/Services/InfoProviderSystem/DTOs/PartDetailDTO.php index 41d50510..9700ae57 100644 --- a/src/Services/InfoProviderSystem/DTOs/PartDetailDTO.php +++ b/src/Services/InfoProviderSystem/DTOs/PartDetailDTO.php @@ -42,6 +42,7 @@ class PartDetailDTO extends SearchResultDTO ?ManufacturingStatus $manufacturing_status = null, ?string $provider_url = null, ?string $footprint = null, + ?string $gtin = null, public readonly ?string $notes = null, /** @var FileDTO[]|null */ public readonly ?array $datasheets = null, @@ -68,6 +69,7 @@ class PartDetailDTO extends SearchResultDTO manufacturing_status: $manufacturing_status, provider_url: $provider_url, footprint: $footprint, + gtin: $gtin ); } } diff --git a/src/Services/InfoProviderSystem/DTOs/SearchResultDTO.php b/src/Services/InfoProviderSystem/DTOs/SearchResultDTO.php index a70b2486..085ae17e 100644 --- a/src/Services/InfoProviderSystem/DTOs/SearchResultDTO.php +++ b/src/Services/InfoProviderSystem/DTOs/SearchResultDTO.php @@ -59,6 +59,8 @@ class SearchResultDTO public readonly ?string $provider_url = null, /** @var string|null A footprint representation of the providers page */ public readonly ?string $footprint = null, + /** @var string|null The GTIN / EAN of the part */ + public readonly ?string $gtin = null, ) { if ($preview_image_url !== null) { @@ -90,6 +92,7 @@ class SearchResultDTO 'manufacturing_status' => $this->manufacturing_status?->value, 'provider_url' => $this->provider_url, 'footprint' => $this->footprint, + 'gtin' => $this->gtin, ]; } @@ -112,6 +115,7 @@ class SearchResultDTO manufacturing_status: isset($data['manufacturing_status']) ? ManufacturingStatus::tryFrom($data['manufacturing_status']) : null, provider_url: $data['provider_url'] ?? null, footprint: $data['footprint'] ?? null, + gtin: $data['gtin'] ?? null, ); } } diff --git a/src/Services/InfoProviderSystem/DTOtoEntityConverter.php b/src/Services/InfoProviderSystem/DTOtoEntityConverter.php index a655a0df..d3a7c52c 100644 --- a/src/Services/InfoProviderSystem/DTOtoEntityConverter.php +++ b/src/Services/InfoProviderSystem/DTOtoEntityConverter.php @@ -175,6 +175,8 @@ final class DTOtoEntityConverter $entity->setManufacturingStatus($dto->manufacturing_status ?? ManufacturingStatus::NOT_SET); $entity->setManufacturerProductURL($dto->manufacturer_product_url ?? ''); + $entity->setGtin($dto->gtin); + //Set the provider reference on the part $entity->setProviderReference(InfoProviderReference::fromPartDTO($dto)); diff --git a/src/Services/InfoProviderSystem/Providers/ConradProvider.php b/src/Services/InfoProviderSystem/Providers/ConradProvider.php index 32434dee..3086b7d8 100644 --- a/src/Services/InfoProviderSystem/Providers/ConradProvider.php +++ b/src/Services/InfoProviderSystem/Providers/ConradProvider.php @@ -120,6 +120,7 @@ readonly class ConradProvider implements InfoProviderInterface, URLHandlerInfoPr preview_image_url: $result['image'] ?? null, provider_url: $this->getProductUrl($result['productId']), footprint: $this->getFootprintFromTechnicalDetails($result['technicalDetails'] ?? []), + gtin: $result['ean'] ?? null, ); } @@ -302,6 +303,7 @@ readonly class ConradProvider implements InfoProviderInterface, URLHandlerInfoPr preview_image_url: $data['productShortInformation']['mainImage']['imageUrl'] ?? null, provider_url: $this->getProductUrl($data['shortProductNumber']), footprint: $this->getFootprintFromTechnicalAttributes($data['productFullInformation']['technicalAttributes'] ?? []), + gtin: $data['productFullInformation']['eanCode'] ?? null, notes: $data['productFullInformation']['description'] ?? null, datasheets: $this->productMediaToDatasheets($data['productMedia'] ?? []), parameters: $this->technicalAttributesToParameters($data['productFullInformation']['technicalAttributes'] ?? []), @@ -316,6 +318,8 @@ readonly class ConradProvider implements InfoProviderInterface, URLHandlerInfoPr ProviderCapabilities::PICTURE, ProviderCapabilities::DATASHEET, ProviderCapabilities::PRICE, + ProviderCapabilities::FOOTPRINT, + ProviderCapabilities::GTIN, ]; } diff --git a/src/Services/InfoProviderSystem/Providers/ProviderCapabilities.php b/src/Services/InfoProviderSystem/Providers/ProviderCapabilities.php index bced19de..21fba53b 100644 --- a/src/Services/InfoProviderSystem/Providers/ProviderCapabilities.php +++ b/src/Services/InfoProviderSystem/Providers/ProviderCapabilities.php @@ -43,6 +43,9 @@ enum ProviderCapabilities /** Information about the footprint of a part */ case FOOTPRINT; + /** Provider can provide GTIN for a part */ + case GTIN; + /** * Get the order index for displaying capabilities in a stable order. * @return int @@ -55,6 +58,7 @@ enum ProviderCapabilities self::DATASHEET => 3, self::PRICE => 4, self::FOOTPRINT => 5, + self::GTIN => 6, }; } @@ -66,6 +70,7 @@ enum ProviderCapabilities self::PICTURE => 'picture', self::DATASHEET => 'datasheet', self::PRICE => 'price', + self::GTIN => 'gtin', }; } @@ -77,6 +82,7 @@ enum ProviderCapabilities self::PICTURE => 'fa-image', self::DATASHEET => 'fa-file-alt', self::PRICE => 'fa-money-bill-wave', + self::GTIN => 'fa-barcode', }; } } diff --git a/templates/info_providers/search/part_search.html.twig b/templates/info_providers/search/part_search.html.twig index 3d741c34..a5602618 100644 --- a/templates/info_providers/search/part_search.html.twig +++ b/templates/info_providers/search/part_search.html.twig @@ -94,7 +94,13 @@ {{ dto.footprint }} {% endif %} - {{ helper.m_status_to_badge(dto.manufacturing_status) }} + + {{ helper.m_status_to_badge(dto.manufacturing_status) }} + {% if dto.gtin %} +
+ {{ dto.gtin }} + {% endif %} + {% if dto.provider_url %} diff --git a/templates/parts/info/_sidebar.html.twig b/templates/parts/info/_sidebar.html.twig index 0c353d8f..12060241 100644 --- a/templates/parts/info/_sidebar.html.twig +++ b/templates/parts/info/_sidebar.html.twig @@ -27,6 +27,14 @@ {% endif %} +{% if part.gtin %} +
+
+ {{ part.gtin }} +
+
+{% endif %} + {# Needs Review tag #} {% if part.needsReview %}
diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index 66053133..f9689089 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -12407,5 +12407,11 @@ Buerklin-API Authentication server: GTIN / EAN + + + info_providers.capabilities.gtin + GTIN / EAN + +