Create/modify product through 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!
lucadambros
Posts: 44
Joined: 24 Jun 2019, 14:46

Create/modify product through API

Post by lucadambros » 12 Jul 2019, 09:59

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?

Code: Select all


Enviroment:
Aimeos 2019.07.02
Laravel 5.8
Mac OS


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

Re: Create/modify product through API

Post by aimeos » 12 Jul 2019, 12:12

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.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

lucadambros
Posts: 44
Joined: 24 Jun 2019, 14:46

Re: Create/modify product through API

Post by lucadambros » 12 Jul 2019, 12:38

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.

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

Re: Create/modify product through API

Post by aimeos » 14 Jul 2019, 11:02

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
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
JawadZaib
Posts: 1
Joined: 28 Jan 2021, 09:58

Re: Create/modify product through API

Post by JawadZaib » 28 Jan 2021, 10:02

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?

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

Re: Create/modify product through API

Post by aimeos » 29 Jan 2021, 09:57

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, Image give us a star

feedtaleone
Posts: 1
Joined: 18 Feb 2021, 11:25

Re: Create/modify product through API

Post by feedtaleone » 18 Feb 2021, 13:26

I need to create a POST and PUT api for the product. How can I do that?

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

Re: Create/modify product through API

Post by aimeos » 20 Feb 2021, 08:45

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.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply