Commit 3df608ce authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

fix error in fairmondo query

parent 09370ef5
......@@ -15,39 +15,52 @@ class Fairmondo extends Searchengine
public function loadResults($result)
{
$results = json_decode($result, true);
$results = $results["articles"];
foreach ($results as $result) {
if ($this->counter >= 10) {
break;
}
try {
$results = json_decode($result, true);
$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'];
if (empty($results)) {
return;
}
$this->counter++;
$this->results[] = new \App\Models\Result(
$this->engine,
$title,
$link,
$anzeigeLink,
$descr,
$this->engine->{"display-name"},$this->engine->homepage,
$this->counter,
[
'price' => $price,
'image' => $image]
);
$results = $results["articles"];
foreach ($results as $result) {
if ($this->counter >= 10) {
break;
}
$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'];
}
$this->counter++;
$this->results[] = new \App\Models\Result(
$this->engine,
$title,
$link,
$anzeigeLink,
$descr,
$this->engine->{"display-name"},
$this->engine->homepage,
$this->counter,
[
'price' => $price,
'image' => $image
]
);
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment