Full product/media control over API
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!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Posts: 14
- Joined: 09 Jun 2021, 15:06
Full product/media control over API
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).
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).
Re: Full product/media control over API
Which Aimeos version are you using?
You want to update the images using the JSON Admin API?
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, give us a star
If you like Aimeos, give us a star
-
- Posts: 14
- Joined: 09 Jun 2021, 15:06
Re: Full product/media control over API
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.
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.
Re: Full product/media control over API
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
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, give us a star
If you like Aimeos, give us a star
-
- Posts: 14
- Joined: 09 Jun 2021, 15:06
Re: Full product/media control over API
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?
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?
Re: Full product/media control over API
Yes, you can find the relevant code from the admin backend here for reference:
https://github.com/aimeos/ai-admin-jqad ... #L354-L407
https://github.com/aimeos/ai-admin-jqad ... #L354-L407
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star