Full product/media control over API

Help for integrating the Laravel package
Forum rules
Always add your Laravel, 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

Full product/media control over API

Post by JakubŽídek » 09 Jun 2021, 15:23

Hello,

I'm new here, so sorry if I break any rules here.

I am building a very specialized e-shop/e-warehouse and I use aimeos API for authentication, product catalogue and basically everything. I don't use a separat database.
I am able to create a new product with the API with a POST request. I get the ID, I can set a name for the product, some description etc.
What I want to ask is this: How do I handle images? Can I somehow create a media object myself, which will I then place in a product's Relationships? I understand that I cannot upload and attach an image to a product over the API, but I was thinking about this workaround (Upload an image to the /files directory -> Create a Media object in Aimeos -> Insert the file URL into the "media.url" of the new Media object -> Put the new Media object inside the "Included" field of the Product).

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

Re: Full product/media control over API

Post by aimeos » 10 Jun 2021, 11:15

Which Aimeos version are you using?
You want to update the images using the JSON Admin API?
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: Full product/media control over API

Post by JakubŽídek » 14 Jun 2021, 08:24

Thank you for your reply,

our AIMEOS version is 2021.04 and we run PHP 7.4.3.

I would like to manage the "media" including images without using the Aimeos backend. So through the JSONapi would be best.

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

Re: Full product/media control over API

Post by aimeos » 14 Jun 2021, 08:43

There's no way to upload image files yet using the JsonAdm API. If you can create a pull request with the necessary change, we will be happy to merge it into the core.

You can find the code for the JsonAdm media endpoint here:
https://github.com/aimeos/ai-admin-json ... andard.php

The methods you have to overwrite in the media endpoint are these one:
- https://github.com/aimeos/ai-admin-json ... #L576-L661
- https://github.com/aimeos/ai-admin-json ... #L281-L375
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: Full product/media control over API

Post by JakubŽídek » 14 Jun 2021, 10:27

Thanks for the reply.

One more question though. If I manage to upload the image to the /files/ using a PHP function, can I then create a "media" object with the Json API and put the file's url into the media.url attribute?

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

Re: Full product/media control over API

Post by aimeos » 14 Jun 2021, 10:34

Yes, you can find the relevant code from the admin backend here for reference:
https://github.com/aimeos/ai-admin-jqad ... #L354-L407
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply