RSS-Bridge / rss-bridge

The RSS feed for websites missing it
https://rss-bridge.org/bridge01/
The Unlicense
7.23k stars 1.03k forks source link

MarktplaatsBridge price filters not working #4000

Open Pizzabroodje opened 6 months ago

Pizzabroodje commented 6 months ago

The marktplaats price filters aren't working.

The solution is quite simple. The minimum and maximum have to be put into the URL in the attributeRanges[] instead of direct attributes. When both are empty, you don't need the attributeRanges. When one of them is left empty, the other one needs to be null. With minimum 100 cents and no maximum, the URL would be like this: "https://www.marktplaats.nl/lrp/api/search?attributeRanges[]=PriceCents%3A100%3Anull&query=..."

To fix it, remove line 125 to 130, and change line 142 to this:

$url = 'https://www.marktplaats.nl/lrp/api/search?' . ((!is_null($this->getInput('f')) || !is_null($this->getInput('t'))) ? 'attributeRanges[]=PriceCents%3A' . $this->getInput('f') ?? 'null' . '%3A' . $this->getInput('t') ?? 'null' . '&' : '') . 'query= . urlencode($this->getInput('q')) . $query;

Not the cleanest code, but it works 😛

Pizzabroodje commented 6 months ago

To get it cleaner I guess you could also just isolate the price range part and/or use variables for the inputs:

$fromPrice = $this->getInput('f');
$toPrice = $this->getInput('t');
$priceRange = (!is_null($fromPrice) || !is_null($toPrice) ? 'attributeRanges[]=PriceCents%3A' . ($fromPrice ?? 'null') . '%3A' . ($toPrice ?? 'null') . '&' : '');

And then just put that into the URL: $url = 'https://www.marktplaats.nl/lrp/api/search?' . $priceRange . urlencode($this->getInput('q')) . $query;

dvikan commented 6 months ago

@Park0

dvikan commented 6 months ago

feel free to provide a patch