Get sku parameters on product
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!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
- FrontEnd07
- Posts: 4
- Joined: 24 May 2023, 11:19
Get sku parameters on product
How can I get sku parameters via api send a request to the address: The issuance goes all in a heap, is this normal?
Code: Select all
http://localhost/jsonapi/product?include=attribute,media,price,product,product/property,text,catalog,supplier,stock&id=4
Re: Get sku parameters on product
The JSON:API response (https://jsonapi.org) contains the found products including the related items in "included" referenced via "relationships" in the products. Thus, variant articles are also referenced via relationships (product.lists.type: "default") from the "included" section and the SKU of products is in the "product.code" property.
You can use a JS library like this one to simplify access to the JSON:API data:
https://github.com/tobyzerner/json-api-models
You can use a JS library like this one to simplify access to the JSON:API data:
https://github.com/tobyzerner/json-api-models
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
- FrontEnd07
- Posts: 4
- Joined: 24 May 2023, 11:19
Re: Get sku parameters on product
Thank you for the response and support of open source aimeos, for me, as a beginner in `JSON:The API` seems complicated to work with, can you give an example of how the 'json-api-models` package will help me sort the sku parameters?aimeos wrote: ↑25 May 2023, 06:22 The JSON:API response (https://jsonapi.org) contains the found products including the related items in "included" referenced via "relationships" in the products. Thus, variant articles are also referenced via relationships (product.lists.type: "default") from the "included" section and the SKU of products is in the "product.code" property.
You can use a JS library like this one to simplify access to the JSON:API data:
https://github.com/tobyzerner/json-api-models
Last edited by FrontEnd07 on 25 May 2023, 08:59, edited 1 time in total.
Re: Get sku parameters on product
The SKUs are in data -> attributes -> product.code in the pure JSON response and you can access them using:
When using the mentioned JS library, it's:
The power of the JS library is in accessing related items that are returnd in the "included" section of the response and they are directly available in the "model".
Code: Select all
fetch(url, options).then(response => {
return response.json()
}).then(response => {
response.data.forEach(item => {
console.log(item.attributes['product.code'])
})
})
Code: Select all
fetch(url, options).then(response => {
return response.json()
}).then(result => {
return (new Store()).sync(result)
}).then(models => {
models.forEach(model => {
console.log(model['product.code'])
})
})
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
- FrontEnd07
- Posts: 4
- Joined: 24 May 2023, 11:19
Re: Get sku parameters on product
So, with one request, there is no way to get everything related to products? That is, you need to collect data through various kinds of queries? Don't you think that this complicates and leads to a big server costs?
- FrontEnd07
- Posts: 4
- Joined: 24 May 2023, 11:19
Re: Get sku parameters on product
I checked the site droppe.com based on aimeos api this site is so slow and slow, it is delayed from replies
Re: Get sku parameters on product
You can get e.g. all product related data in one query using the "include" parameter:FrontEnd07 wrote: ↑28 May 2023, 19:17 So, with one request, there is no way to get everything related to products? That is, you need to collect data through various kinds of queries? Don't you think that this complicates and leads to a big server costs?
https://aimeos.org/docs/latest/frontend ... -resources
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: Get sku parameters on product
The page has a sub-optimal setup and two main problems:FrontEnd07 wrote: ↑28 May 2023, 19:26 I checked the site droppe.com based on aimeos api this site is so slow and slow, it is delayed from replies
1.) The JSON:API and the PWA are on different domains leading to lots of CORS requests
2.) There are too many requests used for data that should be fetched in one request
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
- FrontEnd07
- Posts: 4
- Joined: 24 May 2023, 11:19
Re: Get sku parameters on product
I checked two sites based on `api aimeos` `azexport.az` and `droppe.com` they have the same concept of building requests to api, that is, requests come in batches, this naturally slows down, if it is possible to get answers with one request, then how?
Re: Get sku parameters on product
Like said, please read: https://aimeos.org/docs/latest/frontend ... -resources
Use request like:
Use request like:
Code: Select all
http://localhost:8000/jsonapi/product?include=product.text,media,price,catalog,supplier,attribute,product
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