findologic / findologic-api

Library for sending requests to the Findologic API
MIT License
1 stars 3 forks source link

autocompleteBlocks for the suggest request leads to internal error #76

Closed C3000 closed 3 years ago

C3000 commented 3 years ago

Describe the bug The use of autocompleteBlocks for the suggest request is not possible.

How to reproduce Steps to reproduce the behavior:

  1. Create a new SuggestRequest
  2. Add a autocomplete block with the method addAutocompleteBlocks
  3. A internal error occured

What happens

  1. The function addAutocompleteBlocks expects a string value and adds the value directly to the param.
  2. The url for the api expects an array of autocomplete blocks but get a single value.
  3. An internal error occurde.
  4. The second call of the function addAutocompleteBlocks overrides the first value because the internal use of array_merge_recursive (findologic/findologic-api/src/Requests/Request.php:addParam) gets two strings and returns null.

Expected behavior A valid response is expected.

Screenshots Bildschirmfoto 2021-08-24 um 10 17 11

Environment details:

Additional context Workaround: Use the method addIndividualParam like ->addIndividualParam( SuggestQueryParameter::AUTOCOMPLETEBLOCKS, [BlockType::ORDERNUMBER_BLOCK], SuggestRequest::ADD_VALUE )

TheKeymaster commented 3 years ago

Hello @C3000,

thank you for reporting this issue. I was able to reproduce it with a unit-test, and already prepared a fix in #77 for it. In case you can not wait for the next release, there is also the way to filter the response after sending the request with \FINDOLOGIC\Api\Responses\Autocomplete\SuggestResponse::getFilteredSuggestions().