Use better fields for determine the product name

This commit is contained in:
Jan Böhmer 2026-01-31 21:39:34 +01:00
parent f168b2a83c
commit 2f8553303d

View file

@ -112,8 +112,8 @@ readonly class ConradProvider implements InfoProviderInterface
$out[] = new SearchResultDTO( $out[] = new SearchResultDTO(
provider_key: $this->getProviderKey(), provider_key: $this->getProviderKey(),
provider_id: $result['productId'], provider_id: $result['productId'],
name: $result['title'], name: $result['manufacturerId'] ?? $result['productId'],
description: '', description: $result['title'] ?? '',
manufacturer: $result['brand']['name'] ?? null, manufacturer: $result['brand']['name'] ?? null,
mpn: $result['manufacturerId'] ?? null, mpn: $result['manufacturerId'] ?? null,
preview_image_url: $result['image'] ?? null, preview_image_url: $result['image'] ?? null,
@ -247,7 +247,7 @@ readonly class ConradProvider implements InfoProviderInterface
$minOrderAmount = $result['priceAndAvailabilityFacadeResponse']['priceAndAvailability']['availabilityStatus']['minimumOrderQuantity'] ?? 1; $minOrderAmount = $result['priceAndAvailabilityFacadeResponse']['priceAndAvailability']['availabilityStatus']['minimumOrderQuantity'] ?? 1;
$prices = []; $prices = [];
foreach ($priceInfo['priceScale'] as $priceScale) { foreach ($priceInfo['priceScale'] ?? [] as $priceScale) {
$prices[] = new PriceDTO( $prices[] = new PriceDTO(
minimum_discount_amount: max($priceScale['scaleFrom'], $minOrderAmount), minimum_discount_amount: max($priceScale['scaleFrom'], $minOrderAmount),
price: (string)$priceScale['pricePerUnit'], price: (string)$priceScale['pricePerUnit'],
@ -288,9 +288,9 @@ readonly class ConradProvider implements InfoProviderInterface
return new PartDetailDTO( return new PartDetailDTO(
provider_key: $this->getProviderKey(), provider_key: $this->getProviderKey(),
provider_id: $data['shortProductNumber'], provider_id: $data['shortProductNumber'],
name: $data['productShortInformation']['title'], name: $data['productFullInformation']['manufacturer']['name'] ?? $data['productFullInformation']['manufacturer']['id'] ?? $data['shortProductNumber'],
description: $data['productShortInformation']['shortDescription'] ?? '', description: $data['productShortInformation']['title'] ?? '',
manufacturer: $data['brand']['displayName'] ?? null, manufacturer: $data['brand']['displayName'] !== null ? preg_replace("/[\u{2122}\u{00ae}]/", "", $data['brand']['displayName']) : null, //Replace ™ and ® symbols
mpn: $data['productFullInformation']['manufacturer']['id'] ?? null, mpn: $data['productFullInformation']['manufacturer']['id'] ?? null,
preview_image_url: $data['productShortInformation']['mainImage']['imageUrl'] ?? null, preview_image_url: $data['productShortInformation']['mainImage']['imageUrl'] ?? null,
provider_url: $this->getProductUrl($data['shortProductNumber']), provider_url: $this->getProductUrl($data['shortProductNumber']),