Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MarktplaatsBridge price filters not working #4000

Open
Pizzabroodje opened this issue Mar 6, 2024 · 3 comments
Open

MarktplaatsBridge price filters not working #4000

Pizzabroodje opened this issue Mar 6, 2024 · 3 comments
Labels
Bug-Report Confirmed bug report

Comments

@Pizzabroodje
Copy link

Pizzabroodje commented Mar 6, 2024

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 Pizzabroodje added the Bug-Report Confirmed bug report label Mar 6, 2024
@Pizzabroodje
Copy link
Author

Pizzabroodje commented Mar 7, 2024

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
Copy link
Contributor

dvikan commented Mar 31, 2024

@Park0

@dvikan
Copy link
Contributor

dvikan commented Mar 31, 2024

feel free to provide a patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug-Report Confirmed bug report
Projects
None yet
Development

No branches or pull requests

2 participants