2026-02-01 14:35:58 +01:00
|
|
|
<?php
|
|
|
|
|
/*
|
|
|
|
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2019 - 2026 Jan Böhmer (https://github.com/jbtronics)
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License as published
|
|
|
|
|
* by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace App\Services\InfoProviderSystem\Providers;
|
|
|
|
|
|
2026-02-01 17:34:08 +01:00
|
|
|
use App\Exceptions\ProviderIDNotSupportedException;
|
2026-02-01 18:24:46 +01:00
|
|
|
use App\Services\InfoProviderSystem\DTOs\ParameterDTO;
|
2026-02-01 14:35:58 +01:00
|
|
|
use App\Services\InfoProviderSystem\DTOs\PartDetailDTO;
|
|
|
|
|
use App\Services\InfoProviderSystem\DTOs\PriceDTO;
|
|
|
|
|
use App\Services\InfoProviderSystem\DTOs\PurchaseInfoDTO;
|
2026-02-01 21:18:06 +01:00
|
|
|
use App\Services\InfoProviderSystem\DTOs\SearchResultDTO;
|
2026-02-01 20:49:50 +01:00
|
|
|
use App\Services\InfoProviderSystem\PartInfoRetriever;
|
|
|
|
|
use App\Services\InfoProviderSystem\ProviderRegistry;
|
2026-02-01 17:47:04 +01:00
|
|
|
use App\Settings\InfoProviderSystem\GenericWebProviderSettings;
|
2026-02-01 14:35:58 +01:00
|
|
|
use Symfony\Component\DomCrawler\Crawler;
|
|
|
|
|
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
|
|
|
|
|
|
|
|
|
class GenericWebProvider implements InfoProviderInterface
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public const DISTRIBUTOR_NAME = 'Website';
|
|
|
|
|
|
2026-02-01 16:39:19 +01:00
|
|
|
private readonly HttpClientInterface $httpClient;
|
2026-02-01 14:35:58 +01:00
|
|
|
|
2026-02-01 20:49:50 +01:00
|
|
|
public function __construct(HttpClientInterface $httpClient, private readonly GenericWebProviderSettings $settings,
|
|
|
|
|
private readonly ProviderRegistry $providerRegistry, private readonly PartInfoRetriever $infoRetriever,
|
|
|
|
|
)
|
2026-02-01 16:39:19 +01:00
|
|
|
{
|
|
|
|
|
$this->httpClient = $httpClient->withOptions(
|
|
|
|
|
[
|
|
|
|
|
'headers' => [
|
|
|
|
|
'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36',
|
|
|
|
|
],
|
|
|
|
|
'timeout' => 15,
|
|
|
|
|
]
|
|
|
|
|
);
|
2026-02-01 14:35:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getProviderInfo(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'name' => 'Generic Web URL',
|
2026-02-01 17:47:04 +01:00
|
|
|
'description' => 'Tries to extract a part from a given product webpage URL using common metadata standards like JSON-LD and OpenGraph.',
|
2026-02-01 14:35:58 +01:00
|
|
|
//'url' => 'https://example.com',
|
2026-02-01 17:47:04 +01:00
|
|
|
'disabled_help' => 'Enable in settings to use this provider',
|
|
|
|
|
'settings_class' => GenericWebProviderSettings::class,
|
2026-02-01 14:35:58 +01:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getProviderKey(): string
|
|
|
|
|
{
|
|
|
|
|
return 'generic_web';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function isActive(): bool
|
|
|
|
|
{
|
2026-02-01 17:47:04 +01:00
|
|
|
return $this->settings->enabled;
|
2026-02-01 14:35:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function searchByKeyword(string $keyword): array
|
|
|
|
|
{
|
2026-02-01 21:18:06 +01:00
|
|
|
$url = $this->fixAndValidateURL($keyword);
|
|
|
|
|
|
|
|
|
|
//Before loading the page, try to delegate to another provider
|
|
|
|
|
$delegatedPart = $this->delegateToOtherProvider($url);
|
|
|
|
|
if ($delegatedPart !== null) {
|
|
|
|
|
return [$delegatedPart];
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-01 17:34:08 +01:00
|
|
|
try {
|
2026-02-01 18:24:46 +01:00
|
|
|
return [
|
2026-02-01 21:18:06 +01:00
|
|
|
$this->getDetails($keyword, false) //We already tried delegation
|
2026-02-01 18:24:46 +01:00
|
|
|
]; } catch (ProviderIDNotSupportedException $e) {
|
2026-02-01 17:34:08 +01:00
|
|
|
return [];
|
|
|
|
|
}
|
2026-02-01 14:35:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function extractShopName(string $url): string
|
|
|
|
|
{
|
|
|
|
|
$host = parse_url($url, PHP_URL_HOST);
|
|
|
|
|
if ($host === false || $host === null) {
|
|
|
|
|
return self::DISTRIBUTOR_NAME;
|
|
|
|
|
}
|
|
|
|
|
return $host;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-01 16:39:19 +01:00
|
|
|
private function productJsonLdToPart(array $jsonLd, string $url, Crawler $dom): PartDetailDTO
|
2026-02-01 14:35:58 +01:00
|
|
|
{
|
|
|
|
|
$notes = $jsonLd['description'] ?? "";
|
|
|
|
|
if (isset($jsonLd['disambiguatingDescription'])) {
|
|
|
|
|
if (!empty($notes)) {
|
|
|
|
|
$notes .= "\n\n";
|
|
|
|
|
}
|
|
|
|
|
$notes .= $jsonLd['disambiguatingDescription'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$vendor_infos = null;
|
|
|
|
|
if (isset($jsonLd['offers'])) {
|
2026-02-01 17:06:38 +01:00
|
|
|
|
|
|
|
|
if (array_is_list($jsonLd['offers'])) {
|
|
|
|
|
$offer = $jsonLd['offers'][0];
|
|
|
|
|
} else {
|
|
|
|
|
$offer = $jsonLd['offers'];
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-01 17:11:41 +01:00
|
|
|
//Make $jsonLd['url'] absolute if it's relative
|
|
|
|
|
if (isset($jsonLd['url']) && parse_url($jsonLd['url'], PHP_URL_SCHEME) === null) {
|
|
|
|
|
$parsedUrl = parse_url($url);
|
|
|
|
|
$scheme = $parsedUrl['scheme'] ?? 'https';
|
|
|
|
|
$host = $parsedUrl['host'] ?? '';
|
|
|
|
|
$jsonLd['url'] = $scheme.'://'.$host.$jsonLd['url'];
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-01 17:20:13 +01:00
|
|
|
$prices = [];
|
|
|
|
|
if (isset($offer['price'])) {
|
|
|
|
|
$prices[] = new PriceDTO(
|
|
|
|
|
minimum_discount_amount: 1,
|
|
|
|
|
price: (string) $offer['price'],
|
|
|
|
|
currency_iso_code: $offer['priceCurrency'] ?? null
|
|
|
|
|
);
|
|
|
|
|
} else if (isset($offer['offers']) && array_is_list($offer['offers'])) {
|
|
|
|
|
//Some sites nest offers
|
|
|
|
|
foreach ($offer['offers'] as $subOffer) {
|
|
|
|
|
if (isset($subOffer['price'])) {
|
|
|
|
|
$prices[] = new PriceDTO(
|
|
|
|
|
minimum_discount_amount: 1,
|
|
|
|
|
price: (string) $subOffer['price'],
|
|
|
|
|
currency_iso_code: $subOffer['priceCurrency'] ?? null
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-01 14:35:58 +01:00
|
|
|
$vendor_infos = [new PurchaseInfoDTO(
|
|
|
|
|
distributor_name: $this->extractShopName($url),
|
2026-02-01 17:06:38 +01:00
|
|
|
order_number: (string) ($jsonLd['sku'] ?? $jsonLd['@id'] ?? $jsonLd['gtin'] ?? 'Unknown'),
|
2026-02-01 17:20:13 +01:00
|
|
|
prices: $prices,
|
2026-02-01 14:35:58 +01:00
|
|
|
product_url: $jsonLd['url'] ?? $url,
|
2026-02-01 18:24:46 +01:00
|
|
|
)];
|
2026-02-01 14:35:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$image = null;
|
|
|
|
|
if (isset($jsonLd['image'])) {
|
|
|
|
|
if (is_array($jsonLd['image'])) {
|
2026-02-01 17:20:13 +01:00
|
|
|
if (array_is_list($jsonLd['image'])) {
|
|
|
|
|
$image = $jsonLd['image'][0] ?? null;
|
|
|
|
|
}
|
2026-02-01 14:35:58 +01:00
|
|
|
} elseif (is_string($jsonLd['image'])) {
|
|
|
|
|
$image = $jsonLd['image'];
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-01 17:20:13 +01:00
|
|
|
//If image is an object with @type ImageObject, extract the url
|
|
|
|
|
if (is_array($image) && isset($image['@type']) && $image['@type'] === 'ImageObject') {
|
|
|
|
|
$image = $image['contentUrl'] ?? $image['url'] ?? null;
|
|
|
|
|
}
|
2026-02-01 14:35:58 +01:00
|
|
|
|
2026-02-01 18:24:46 +01:00
|
|
|
//Try to extract parameters from additionalProperty
|
|
|
|
|
$parameters = [];
|
|
|
|
|
if (isset($jsonLd['additionalProperty']) && array_is_list($jsonLd['additionalProperty'])) {
|
|
|
|
|
foreach ($jsonLd['additionalProperty'] as $property) { //TODO: Handle minValue and maxValue
|
|
|
|
|
if (isset ($property['unitText'])) {
|
|
|
|
|
$parameters[] = ParameterDTO::parseValueField(
|
|
|
|
|
name: $property['name'] ?? 'Unknown',
|
|
|
|
|
value: $property['value'] ?? '',
|
|
|
|
|
unit: $property['unitText']
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
$parameters[] = ParameterDTO::parseValueIncludingUnit(
|
|
|
|
|
name: $property['name'] ?? 'Unknown',
|
|
|
|
|
value: $property['value'] ?? ''
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2026-02-01 14:35:58 +01:00
|
|
|
return new PartDetailDTO(
|
|
|
|
|
provider_key: $this->getProviderKey(),
|
|
|
|
|
provider_id: $url,
|
|
|
|
|
name: $jsonLd ['name'] ?? 'Unknown Name',
|
2026-02-01 16:39:19 +01:00
|
|
|
description: $this->getMetaContent($dom, 'og:description') ?? $this->getMetaContent($dom, 'description') ?? '',
|
2026-02-01 14:35:58 +01:00
|
|
|
category: isset($jsonLd['category']) && is_string($jsonLd['category']) ? $jsonLd['category'] : null,
|
|
|
|
|
manufacturer: $jsonLd['manufacturer']['name'] ?? $jsonLd['brand']['name'] ?? null,
|
|
|
|
|
mpn: $jsonLd['mpn'] ?? null,
|
2026-02-01 18:24:46 +01:00
|
|
|
preview_image_url: $image,
|
2026-02-01 14:35:58 +01:00
|
|
|
provider_url: $url,
|
|
|
|
|
notes: $notes,
|
2026-02-01 18:24:46 +01:00
|
|
|
parameters: $parameters,
|
2026-02-01 14:35:58 +01:00
|
|
|
vendor_infos: $vendor_infos,
|
|
|
|
|
mass: isset($jsonLd['weight']['value']) ? (float)$jsonLd['weight']['value'] : null,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Decodes JSON in a forgiving way, trying to fix common issues.
|
|
|
|
|
* @param string $json
|
|
|
|
|
* @return array
|
|
|
|
|
* @throws \JsonException
|
|
|
|
|
*/
|
|
|
|
|
private function json_decode_forgiving(string $json): array
|
|
|
|
|
{
|
|
|
|
|
//Sanitize common issues
|
|
|
|
|
$json = preg_replace("/[\r\n]+/", " ", $json);
|
|
|
|
|
return json_decode($json, true, 512, JSON_THROW_ON_ERROR);
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-01 21:19:11 +01:00
|
|
|
/**
|
|
|
|
|
* Gets the content of a meta tag by its name or property attribute, or null if not found
|
|
|
|
|
* @param Crawler $dom
|
|
|
|
|
* @param string $name
|
|
|
|
|
* @return string|null
|
|
|
|
|
*/
|
2026-02-01 16:39:19 +01:00
|
|
|
private function getMetaContent(Crawler $dom, string $name): ?string
|
|
|
|
|
{
|
|
|
|
|
$meta = $dom->filter('meta[property="'.$name.'"]');
|
|
|
|
|
if ($meta->count() > 0) {
|
|
|
|
|
return $meta->attr('content');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Try name attribute
|
|
|
|
|
$meta = $dom->filter('meta[name="'.$name.'"]');
|
|
|
|
|
if ($meta->count() > 0) {
|
|
|
|
|
return $meta->attr('content');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-01 20:49:50 +01:00
|
|
|
/**
|
|
|
|
|
* Delegates the URL to another provider if possible, otherwise return null
|
|
|
|
|
* @param string $url
|
2026-02-01 21:18:06 +01:00
|
|
|
* @return SearchResultDTO|null
|
2026-02-01 20:49:50 +01:00
|
|
|
*/
|
2026-02-01 21:18:06 +01:00
|
|
|
private function delegateToOtherProvider(string $url): ?SearchResultDTO
|
2026-02-01 20:49:50 +01:00
|
|
|
{
|
|
|
|
|
//Extract domain from url:
|
|
|
|
|
$host = parse_url($url, PHP_URL_HOST);
|
|
|
|
|
if ($host === false || $host === null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$provider = $this->providerRegistry->getProviderHandlingDomain($host);
|
|
|
|
|
|
|
|
|
|
if ($provider !== null && $provider->isActive() && $provider->getProviderKey() !== $this->getProviderKey()) {
|
|
|
|
|
try {
|
|
|
|
|
$id = $provider->getIDFromURL($url);
|
|
|
|
|
if ($id !== null) {
|
2026-02-01 21:18:06 +01:00
|
|
|
$results = $this->infoRetriever->searchByKeyword($id, [$provider]);
|
|
|
|
|
if (count($results) > 0) {
|
|
|
|
|
return $results[0];
|
|
|
|
|
}
|
2026-02-01 20:49:50 +01:00
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
} catch (ProviderIDNotSupportedException $e) {
|
|
|
|
|
//Ignore and continue
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-01 21:18:06 +01:00
|
|
|
private function fixAndValidateURL(string $url): string
|
2026-02-01 14:35:58 +01:00
|
|
|
{
|
2026-02-01 21:18:06 +01:00
|
|
|
$originalUrl = $url;
|
|
|
|
|
|
2026-02-01 16:55:52 +01:00
|
|
|
//Add scheme if missing
|
2026-02-01 21:18:06 +01:00
|
|
|
if (!preg_match('/^https?:\/\//', $url)) {
|
2026-02-01 16:55:52 +01:00
|
|
|
//Remove any leading slashes
|
2026-02-01 21:18:06 +01:00
|
|
|
$url = ltrim($url, '/');
|
2026-02-01 16:55:52 +01:00
|
|
|
|
2026-02-01 21:18:06 +01:00
|
|
|
$url = 'https://'.$url;
|
2026-02-01 16:55:52 +01:00
|
|
|
}
|
|
|
|
|
|
2026-02-01 17:34:08 +01:00
|
|
|
//If this is not a valid URL with host, domain and path, throw an exception
|
|
|
|
|
if (filter_var($url, FILTER_VALIDATE_URL) === false ||
|
|
|
|
|
parse_url($url, PHP_URL_HOST) === null ||
|
|
|
|
|
parse_url($url, PHP_URL_PATH) === null) {
|
2026-02-01 21:18:06 +01:00
|
|
|
throw new ProviderIDNotSupportedException("The given ID is not a valid URL: ".$originalUrl);
|
2026-02-01 17:34:08 +01:00
|
|
|
}
|
|
|
|
|
|
2026-02-01 21:18:06 +01:00
|
|
|
return $url;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getDetails(string $id, bool $check_for_delegation = true): PartDetailDTO
|
|
|
|
|
{
|
|
|
|
|
$url = $this->fixAndValidateURL($id);
|
|
|
|
|
|
|
|
|
|
if ($check_for_delegation) {
|
|
|
|
|
//Before loading the page, try to delegate to another provider
|
|
|
|
|
$delegatedPart = $this->delegateToOtherProvider($url);
|
|
|
|
|
if ($delegatedPart !== null) {
|
2026-02-01 21:19:11 +01:00
|
|
|
return $this->infoRetriever->getDetailsForSearchResult($delegatedPart);
|
2026-02-01 21:18:06 +01:00
|
|
|
}
|
2026-02-01 20:49:50 +01:00
|
|
|
}
|
|
|
|
|
|
2026-02-01 14:35:58 +01:00
|
|
|
//Try to get the webpage content
|
|
|
|
|
$response = $this->httpClient->request('GET', $url);
|
|
|
|
|
$content = $response->getContent();
|
|
|
|
|
|
|
|
|
|
$dom = new Crawler($content);
|
|
|
|
|
|
|
|
|
|
//Try to determine a canonical URL
|
|
|
|
|
$canonicalURL = $url;
|
|
|
|
|
if ($dom->filter('link[rel="canonical"]')->count() > 0) {
|
|
|
|
|
$canonicalURL = $dom->filter('link[rel="canonical"]')->attr('href');
|
|
|
|
|
} else if ($dom->filter('meta[property="og:url"]')->count() > 0) {
|
|
|
|
|
$canonicalURL = $dom->filter('meta[property="og:url"]')->attr('content');
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-01 17:11:41 +01:00
|
|
|
//If the canonical URL is relative, make it absolute
|
|
|
|
|
if (parse_url($canonicalURL, PHP_URL_SCHEME) === null) {
|
|
|
|
|
$parsedUrl = parse_url($url);
|
|
|
|
|
$scheme = $parsedUrl['scheme'] ?? 'https';
|
|
|
|
|
$host = $parsedUrl['host'] ?? '';
|
|
|
|
|
$canonicalURL = $scheme.'://'.$host.$canonicalURL;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-01 14:35:58 +01:00
|
|
|
//Try to find json-ld data in the head
|
2026-02-01 16:39:19 +01:00
|
|
|
$jsonLdNodes = $dom->filter('script[type="application/ld+json"]');
|
2026-02-01 14:35:58 +01:00
|
|
|
foreach ($jsonLdNodes as $node) {
|
|
|
|
|
$jsonLd = $this->json_decode_forgiving($node->textContent);
|
2026-02-01 17:06:38 +01:00
|
|
|
//If the content of json-ld is an array, try to find a product inside
|
|
|
|
|
if (!array_is_list($jsonLd)) {
|
|
|
|
|
$jsonLd = [$jsonLd];
|
|
|
|
|
}
|
|
|
|
|
foreach ($jsonLd as $item) {
|
|
|
|
|
if (isset($item['@type']) && $item['@type'] === 'Product') {
|
|
|
|
|
return $this->productJsonLdToPart($item, $canonicalURL, $dom);
|
|
|
|
|
}
|
2026-02-01 14:35:58 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-01 16:39:19 +01:00
|
|
|
//If no JSON-LD data is found, try to extract basic data from meta tags
|
|
|
|
|
$pageTitle = $dom->filter('title')->count() > 0 ? $dom->filter('title')->text() : 'Unknown';
|
2026-02-01 14:35:58 +01:00
|
|
|
|
2026-02-01 16:39:19 +01:00
|
|
|
$prices = [];
|
|
|
|
|
if ($price = $this->getMetaContent($dom, 'product:price:amount')) {
|
|
|
|
|
$prices[] = new PriceDTO(
|
|
|
|
|
minimum_discount_amount: 1,
|
|
|
|
|
price: $price,
|
|
|
|
|
currency_iso_code: $this->getMetaContent($dom, 'product:price:currency'),
|
|
|
|
|
);
|
2026-02-01 16:51:26 +01:00
|
|
|
} else {
|
|
|
|
|
//Amazon fallback
|
|
|
|
|
$amazonAmount = $dom->filter('input[type="hidden"][name*="amount"]');
|
|
|
|
|
if ($amazonAmount->count() > 0) {
|
|
|
|
|
$prices[] = new PriceDTO(
|
|
|
|
|
minimum_discount_amount: 1,
|
|
|
|
|
price: $amazonAmount->first()->attr('value'),
|
|
|
|
|
currency_iso_code: $dom->filter('input[type="hidden"][name*="currencyCode"]')->first()->attr('value'),
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-02-01 16:39:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$vendor_infos = [new PurchaseInfoDTO(
|
|
|
|
|
distributor_name: $this->extractShopName($canonicalURL),
|
|
|
|
|
order_number: 'Unknown',
|
|
|
|
|
prices: $prices,
|
|
|
|
|
product_url: $canonicalURL,
|
|
|
|
|
)];
|
|
|
|
|
|
|
|
|
|
return new PartDetailDTO(
|
|
|
|
|
provider_key: $this->getProviderKey(),
|
|
|
|
|
provider_id: $canonicalURL,
|
|
|
|
|
name: $this->getMetaContent($dom, 'og:title') ?? $pageTitle,
|
|
|
|
|
description: $this->getMetaContent($dom, 'og:description') ?? $this->getMetaContent($dom, 'description') ?? '',
|
|
|
|
|
manufacturer: $this->getMetaContent($dom, 'product:brand'),
|
|
|
|
|
preview_image_url: $this->getMetaContent($dom, 'og:image'),
|
|
|
|
|
provider_url: $canonicalURL,
|
|
|
|
|
vendor_infos: $vendor_infos,
|
|
|
|
|
);
|
2026-02-01 14:35:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getCapabilities(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
ProviderCapabilities::BASIC,
|
|
|
|
|
ProviderCapabilities::PICTURE,
|
|
|
|
|
ProviderCapabilities::PRICE
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|