Page 2 of 2

Re: Help with Json API - Filtering the product list

Posted: 20 Mar 2018, 16:31
by aimeos

Re: Help with Json API - Filtering the product list

Posted: 15 Jul 2018, 13:45
by kisese
HI,
A little help whenever i run the filter
http://localhost:8000/jsonapi/product?filter[=~][product.type]=select

I get all results instead of the filtered result. Also the example in the documentation

http://localhost:8000/jsonapi/product?filter[>][product.type.code]=select

for getting products of type "select" does not return correct data.

Kindly assist :)

Aimeos version: 2017.10
PHP version: 7.1
Package: Laravel
Environment: Windows

Re: Help with Json API - Filtering the product list

Posted: 17 Jul 2018, 22:30
by aimeos
kisese wrote: I get all results instead of the filtered result:
http://localhost:8000/jsonapi/product?filter[=~][product.type]=select
If you put that into the address line of you browser, the "=~" will be interpreted as "filter[", "=" and "~][product..." which isn't passed to the server correctly. The second problem is that "product.type" is a added to the result for simplification but only "product.type.code" remains a valid search key.
kisese wrote: Getting products of type "select" does not return correct data:
http://localhost:8000/jsonapi/product?filter[>][product.type.code]=select
This filter does return all products whose type is lexicographically beyond "select". In the latest Aimeos version it will return products of type "voucher", in your version it will return nothing.

The correct URL for pasting into the browser would be:

Code: Select all

http://localhost:8000/jsonapi/product?filter%5B%3D%3D%5D%5Bproduct.type.code%5D=select
like stated in the docs. If you pass the "{"filter": {"==": {"product.type.code":"select"}}}" JS object to e.g. to the jQuery $.ajax() method, it will get encoded automatically.

Re: Help with Json API - Filtering the product list

Posted: 18 Jul 2018, 10:08
by kisese
Thank you very much, I get it now. and thanks for the wonderful product. :) :)