Fairmondo.php 1.49 KB
Newer Older
1
2
3
<?php

namespace app\Models\parserSkripte;
4

5
6
use App\Models\Searchengine;

7
class Fairmondo extends Searchengine
8
{
9
10
11
12
13
14
    public $results = [];

    public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager)
    {
        parent::__construct($engine, $metager);
    }
15

16
17
18
19
20
21
22
23
    public function loadResults($result)
    {
        $results = json_decode($result, true);
        $results = $results["articles"];
        foreach ($results as $result) {
            if ($this->counter >= 10) {
                break;
            }
24

25
26
27
28
29
30
31
32
33
34
35
36
            $title       = $result["title"];
            $link        = "https://www.fairmondo.de/articles/" . $result["id"];
            $anzeigeLink = $link;
            $price       = 0;
            $descr       = "";
            if (isset($result['price_cents'])) {
                $price = intval($result['price_cents']);
                $descr .= "<p>Preis: " . (intval($result['price_cents']) / 100.0) . " €</p>";
            }
            if (isset($result['title_image_url'])) {
                $image = $result['title_image_url'];
            }
37

38
39
40
41
42
43
44
            $this->counter++;
            $this->results[] = new \App\Models\Result(
                $this->engine,
                $title,
                $link,
                $anzeigeLink,
                $descr,
45
                $this->displayName,$this->homepage,
46
                $this->counter,
47
48
49
                [
                    'price' => $price,
                    'image' => $image]
50
51
52
53
            );
        }
    }
}