Create/modify product through 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: 44
- Joined: 24 Jun 2019, 14:46
Create/modify product through API
Hi,
How can I create/modify a product through API?
I need to create a POST and PUT api for the product. How can I do that?
How can I create/modify a product through API?
I need to create a POST and PUT api for the product. How can I do that?
Code: Select all
Enviroment:
Aimeos 2019.07.02
Laravel 5.8
Mac OS
Re: Create/modify product through API
The JSON REST API for the admin interface gives you full control over the product data (you only have to authenticate in some way before):
https://aimeos.org/docs/Developers/Admin/JSONAPI
Unfortunately, REST APIs don't let you push the whole data at once to the server because the product in Aimeos consists of several resources (media, texts, prices, attributes, etc.). If you can't or don't want to use several calls to the REST API (saving media, texts, etc, then the product data itself and at the end the category/product relation), you can implement your own controller action that takes all data and creates the complete product object that can be saved at once.
We are planning a GraphQL API in the future which won't have that restriction.
https://aimeos.org/docs/Developers/Admin/JSONAPI
Unfortunately, REST APIs don't let you push the whole data at once to the server because the product in Aimeos consists of several resources (media, texts, prices, attributes, etc.). If you can't or don't want to use several calls to the REST API (saving media, texts, etc, then the product data itself and at the end the category/product relation), you can implement your own controller action that takes all data and creates the complete product object that can be saved at once.
We are planning a GraphQL API in the future which won't have that restriction.
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: 44
- Joined: 24 Jun 2019, 14:46
Re: Create/modify product through API
Well, I have to create more API calls but how can I do that?
In the documentation I can't find how to create an API but only how to use them.
In the documentation I can't find how to create an API but only how to use them.
Re: Create/modify product through API
Use the standard Laravel way to create new controller/actions for your API. Here you can read how to get the Aimeos context so your can use the managers to create new products or other items:
- https://aimeos.org/docs/Laravel/Extend_Aimeos
- https://aimeos.org/docs/Developers#Managers_and_items
- https://aimeos.org/docs/Laravel/Extend_Aimeos
- https://aimeos.org/docs/Developers#Managers_and_items
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
Re: Create/modify product through API
We can use context and manager object to build custom API for aimeos data. But is it possible to use same response like aimeos has and we pass our data to it. Or is there way to remove default filters from product api frontend?
Re: Create/modify product through API
Unsure what you want to do but the frontend JSON REST API (ai-client-jsonapi) is only for interacting with Javascript from the clients browser and not for managing products (only fething data and creating orders for the customer).
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: 1
- Joined: 18 Feb 2021, 11:25
Re: Create/modify product through API
I need to create a POST and PUT api for the product. How can I do that?
Re: Create/modify product through API
For creating products, you have to use the JsonAdm API:
https://aimeos.org/docs/latest/admin/js ... eate-items
Remember that you have to be logged in into the admin backend or use one of the Laravel API authentication packages.
https://aimeos.org/docs/latest/admin/js ... eate-items
Remember that you have to be logged in into the admin backend or use one of the Laravel API authentication packages.
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