mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-20 17:15:51 +02:00
Use correct price for one unit if there are multiple prices availble
We can still not parse the bulk prices correctly completly
This commit is contained in:
parent
742e57cc5c
commit
9b35b60d61
1 changed files with 20 additions and 10 deletions
|
@ -141,16 +141,7 @@ class PollinProvider implements InfoProviderInterface
|
|||
$mass = (float) $massStr * 1000;
|
||||
|
||||
//Parse purchase info
|
||||
$purchaseInfo = new PurchaseInfoDTO(
|
||||
'Pollin',
|
||||
$orderId,
|
||||
[
|
||||
new PriceDTO(1, $dom->filter('meta[property="product:price:amount"]')->attr('content'), $dom->filter('meta[property="product:price:currency"]')->attr('content'))
|
||||
],
|
||||
$productPageUrl
|
||||
);
|
||||
|
||||
|
||||
$purchaseInfo = new PurchaseInfoDTO('Pollin', $orderId, $this->parsePrices($dom), $productPageUrl);
|
||||
|
||||
return new PartDetailDTO(
|
||||
provider_key: $this->getProviderKey(),
|
||||
|
@ -221,6 +212,25 @@ class PollinProvider implements InfoProviderInterface
|
|||
return $dom->filter('div.product-detail-top-features')->html() . '<br><br>' . $dom->filter('div.product-detail-description-text')->html();
|
||||
}
|
||||
|
||||
private function parsePrices(Crawler $dom): array
|
||||
{
|
||||
//TODO: Properly handle multiple prices, for now we just look at the price for one piece
|
||||
|
||||
//We assume the currency is always the same
|
||||
$currency = $dom->filter('meta[property="product:price:currency"]')->attr('content');
|
||||
|
||||
//If there is meta[property=highPrice] then use this as the price
|
||||
if ($dom->filter('meta[itemprop="highPrice"]')->count() > 0) {
|
||||
$price = $dom->filter('meta[itemprop="highPrice"]')->attr('content');
|
||||
} else {
|
||||
$price = $dom->filter('meta[property="product:price:amount"]')->attr('content');
|
||||
}
|
||||
|
||||
return [
|
||||
new PriceDTO(1.0, $price, $currency)
|
||||
];
|
||||
}
|
||||
|
||||
public function getCapabilities(): array
|
||||
{
|
||||
return [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue