Skip to content

Commit b8064d9

Browse files
authored
[EpicGamesFree] Fixes: url not set, other promos shown (#4575)
* URI was not set because of the typo * Filter out other promos
1 parent 9762171 commit b8064d9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

bridges/EpicGamesFreeBridge.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class EpicGamesFreeBridge extends BridgeAbstract
2727
'Türkçe' => 'tr',
2828
'简体中文' => 'zh-CN',
2929
'繁體中文' => 'zh-Hant',
30-
],
30+
],
3131
'title' => 'Language for game information',
3232
'defaultValue' => 'en-US',
3333
],
@@ -51,16 +51,21 @@ public function collectData()
5151

5252
$data = $json['data']['Catalog']['searchStore']['elements'];
5353
foreach ($data as $element) {
54-
if (!isset($element['promotions']['promotionalOffers'][0])) {
54+
$promo = $element['promotions']['promotionalOffers'][0]['promotionalOffers'][0] ?? false;
55+
if (
56+
!$promo ||
57+
$promo['discountSetting']['discountType'] !== 'PERCENTAGE' ||
58+
$promo['discountSetting']['discountPercentage'] !== 0
59+
) {
5560
continue;
5661
}
5762
$item = [
5863
'author' => $element['seller']['name'],
5964
'content' => $element['description'],
6065
'enclosures' => array_map(fn($item) => $item['url'], $element['keyImages']),
61-
'timestamp' => strtotime($element['promotions']['promotionalOffers'][0]['promotionalOffers'][0]['startDate']),
66+
'timestamp' => strtotime($promo['startDate']),
6267
'title' => $element['title'],
63-
'url' => parent::getURI() . $this->getInput('locale') . '/p/' . $element['urlSlug'],
68+
'uri' => parent::getURI() . $this->getInput('locale') . '/p/' . $element['productSlug'],
6469
];
6570
$this->items[] = $item;
6671
}

0 commit comments

Comments
 (0)