mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Allow to extract MPN from reichelt provider
This commit is contained in:
parent
f1c28b9f46
commit
a798aa9c24
1 changed files with 14 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue