JsonAPI get all products from a supplier

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
JakubŽídek
Posts: 14
Joined: 09 Jun 2021, 15:06

JsonAPI get all products from a supplier

Post by JakubŽídek » 07 Oct 2022, 12:25

Hello, our AIMEOS version is 2021.04 and we run PHP 7.4.3.

I've been using Aimeos pretty successfully, but I have ran into a roadblock. I need to make an API call to retrieve all products of a certain supplier.

If I want to retrieve a single product, I make this call:
"https://MYURL/admin/default/jsonadm/product?include=media,text,price&filter[||][][%3D%3D][product.id]=60"

And this works great. But, how do I do something like:

"https://MYURL/admin/default/jsonadm/product?include=media,text,price&filter[||][][%3D%3D][product.attributes.supplier.id]=12"?

Is there a way to do this?

I tried going around it by retrieving all the products of a certain supplier and then getting those products with:

"https://MYURL/admin/default/jsonadm/product?include=media,text,price&filter[||][][%3D%3D][product.id]=60&filter[||][][%3D%3D][product.id]=61&filter[||][][%3D%3D][product.id]=62&filter[||][][%3D%3D][product.id]=63&filter[||][][%3D%3D][product.id]=64&filter[||][][%3D%3D][product.id]=65&filter[||][][%3D%3D][product.id]=66"

But with this I reach the 2000 character max URL length pretty easily and it's just clunky.

Thanks for any suggestions!

User avatar
aimeos
Administrator
Posts: 7906
Joined: 01 Jan 1970, 00:00

Re: JsonAPI get all products from a supplier

Post by aimeos » 09 Oct 2022, 07:55

Aimeos 2021.04 isn't supported any more. Please upgrade at least to 2021.10.

In 2021.x, it's hard to get the products with a specific supplier attached in the admin JSON API (frontend works without problems if you use the "index" endpoint but that's not available in the admin backend).

In 2022.x, this got easy because suppliers are attached to products now (not products to suppliers like before) and you can query products with a supplier using:

Code: Select all

/admin/default/jsonadm/product?filter[!=][product:has("supplier","default",12)]=
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

JakubŽídek
Posts: 14
Joined: 09 Jun 2021, 15:06

Re: JsonAPI get all products from a supplier

Post by JakubŽídek » 10 Oct 2022, 05:20

Thank you very much for your response.

Would there be any risk in updating our Aimeos version? Like, did any database structure change? I have a pretty extensive custom API I made and I worry it will all break if there are any collumns removed or renamed etc.

Thanks again!

User avatar
aimeos
Administrator
Posts: 7906
Joined: 01 Jan 1970, 00:00

Re: JsonAPI get all products from a supplier

Post by aimeos » 11 Oct 2022, 06:02

When migrating to 2022.10, there are some breaking changes you need to care about:
https://aimeos.org/docs/latest/changelog/2022.x/

Updating to 2021.10 shouldn't break anything but the frontend theme is different.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply