mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Extract category from reichelt provider
This commit is contained in:
parent
e0bf8e5fbc
commit
e287918121
1 changed files with 24 additions and 0 deletions
|
@ -131,6 +131,7 @@ class ReicheltProvider implements InfoProviderInterface
|
||||||
provider_id: $id,
|
provider_id: $id,
|
||||||
name: $json[0]['article_artnr'],
|
name: $json[0]['article_artnr'],
|
||||||
description: $json[0]['article_besch'],
|
description: $json[0]['article_besch'],
|
||||||
|
category: $this->parseCategory($dom),
|
||||||
manufacturer: $json[0]['manufacturer_name'],
|
manufacturer: $json[0]['manufacturer_name'],
|
||||||
preview_image_url: $json[0]['article_picture'],
|
preview_image_url: $json[0]['article_picture'],
|
||||||
provider_url: $productPage,
|
provider_url: $productPage,
|
||||||
|
@ -141,6 +142,29 @@ class ReicheltProvider implements InfoProviderInterface
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function parseCategory(Crawler $dom): string
|
||||||
|
{
|
||||||
|
// Look for ol.breadcrumb and iterate over the li elements
|
||||||
|
$category = '';
|
||||||
|
$dom->filter('ol.breadcrumb li.triangle-left')->each(function (Crawler $element) use (&$category) {
|
||||||
|
//Do not include the .breadcrumb-showmore element
|
||||||
|
if ($element->attr('id') === 'breadcrumb-showmore') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$category .= $element->text() . ' -> ';
|
||||||
|
});
|
||||||
|
//Remove the trailing ' -> '
|
||||||
|
$category = substr($category, 0, -4);
|
||||||
|
|
||||||
|
return $category;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Crawler $dom
|
||||||
|
* @return ParameterDTO[]
|
||||||
|
*/
|
||||||
private function parseParameters(Crawler $dom): array
|
private function parseParameters(Crawler $dom): array
|
||||||
{
|
{
|
||||||
$parameters = [];
|
$parameters = [];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue