From a798aa9c249bfcf119fa48ae2279f8050921d837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Thu, 20 Feb 2025 15:39:35 +0100 Subject: [PATCH] Allow to extract MPN from reichelt provider --- .../Providers/ReicheltProvider.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Services/InfoProviderSystem/Providers/ReicheltProvider.php b/src/Services/InfoProviderSystem/Providers/ReicheltProvider.php index bffb9279..8905ea76 100644 --- a/src/Services/InfoProviderSystem/Providers/ReicheltProvider.php +++ b/src/Services/InfoProviderSystem/Providers/ReicheltProvider.php @@ -147,6 +147,7 @@ class ReicheltProvider implements InfoProviderInterface description: $json[0]['article_besch'], category: $this->parseCategory($dom), manufacturer: $json[0]['manufacturer_name'], + mpn: $this->parseMPN($dom), preview_image_url: $json[0]['article_picture'], provider_url: $productPage, notes: $notes, @@ -157,6 +158,19 @@ class ReicheltProvider implements InfoProviderInterface } + private function parseMPN(Crawler $dom): ?string + { + //Find the small element directly after meta[itemprop="url"] element + $element = $dom->filter('meta[itemprop="url"] + small'); + //If the text contains GTIN text, take the small element afterwards + if (str_contains($element->text(), 'GTIN')) { + $element = $dom->filter('meta[itemprop="url"] + small + small'); + } + + //The MPN is contained in the span inside the element + return $element->filter('span')->text(); + } + private function parseBatchPrices(Crawler $dom): array { //Iterate over each a.inline-block element in div.discountValue