Merge branch 'gtin'

This commit is contained in:
Jan Böhmer 2026-02-14 22:12:39 +01:00
commit 7a83581597
71 changed files with 1405 additions and 92 deletions

View file

@ -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,
];
}

View file

@ -227,10 +227,11 @@ class GenericWebProvider implements InfoProviderInterface
mpn: $product->mpn?->toString(),
preview_image_url: $image,
provider_url: $url,
gtin: $product->gtin14?->toString() ?? $product->gtin13?->toString() ?? $product->gtin12?->toString() ?? $product->gtin8?->toString(),
notes: $notes,
parameters: $parameters,
vendor_infos: $vendor_infos,
mass: $mass
mass: $mass,
);
}
@ -429,7 +430,8 @@ class GenericWebProvider implements InfoProviderInterface
return [
ProviderCapabilities::BASIC,
ProviderCapabilities::PICTURE,
ProviderCapabilities::PRICE
ProviderCapabilities::PRICE,
ProviderCapabilities::GTIN,
];
}
}

View file

@ -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',
};
}
}

View file

@ -84,6 +84,8 @@ class ReicheltProvider implements InfoProviderInterface
$name = $element->filter('meta[itemprop="name"]')->attr('content');
$sku = $element->filter('meta[itemprop="sku"]')->attr('content');
//Try to extract a picture URL:
$pictureURL = $element->filter("div.al_artlogo img")->attr('src');
@ -95,7 +97,8 @@ class ReicheltProvider implements InfoProviderInterface
category: null,
manufacturer: $sku,
preview_image_url: $pictureURL,
provider_url: $element->filter('a.al_artinfo_link')->attr('href')
provider_url: $element->filter('a.al_artinfo_link')->attr('href'),
);
});
@ -146,6 +149,15 @@ class ReicheltProvider implements InfoProviderInterface
$priceString = $dom->filter('meta[itemprop="price"]')->attr('content');
$currency = $dom->filter('meta[itemprop="priceCurrency"]')->attr('content', 'EUR');
$gtin = null;
foreach (['gtin13', 'gtin14', 'gtin12', 'gtin8'] as $gtinType) {
if ($dom->filter("[itemprop=\"$gtinType\"]")->count() > 0) {
$gtin = $dom->filter("[itemprop=\"$gtinType\"]")->innerText();
break;
}
}
//Create purchase info
$purchaseInfo = new PurchaseInfoDTO(
distributor_name: self::DISTRIBUTOR_NAME,
@ -167,10 +179,11 @@ class ReicheltProvider implements InfoProviderInterface
mpn: $this->parseMPN($dom),
preview_image_url: $json[0]['article_picture'],
provider_url: $productPage,
gtin: $gtin,
notes: $notes,
datasheets: $datasheets,
parameters: $this->parseParameters($dom),
vendor_infos: [$purchaseInfo]
vendor_infos: [$purchaseInfo],
);
}
@ -273,6 +286,7 @@ class ReicheltProvider implements InfoProviderInterface
ProviderCapabilities::PICTURE,
ProviderCapabilities::DATASHEET,
ProviderCapabilities::PRICE,
ProviderCapabilities::GTIN,
];
}
}