JSON API - create new product and add existing Attributes with Product.lists.type
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!
JSON API - create new product and add existing Attributes with Product.lists.type
Hi there,
I am currently using Aimeos laravel ver 2020.10*
- I am using JSON API to create a variant article with existing attributes to include to Selection product
below Image is the data in the request.
- The problem is after submitting, the product.list.type = variant is automatically change to 'default'
I am currently using Aimeos laravel ver 2020.10*
- I am using JSON API to create a variant article with existing attributes to include to Selection product
below Image is the data in the request.
- The problem is after submitting, the product.list.type = variant is automatically change to 'default'
- Attachments
-
- Screen Shot 2020-12-03 at 4.05.17 PM.png (61.46 KiB) Viewed 9151 times
Re: JSON API - create new product and add existing Attributes with Product.lists.type
Can you please post your full request and response including the code for building the request?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

Re: JSON API - create new product and add existing Attributes with Product.lists.type
this is the data in the POST request
{
"type": "product",
"attributes": {
"product.status": 1,
"product.type": "default",
"product.label": "label size S yellow",
"product.code": "testselectioncreate-size-S-yellow"
},
"relationships": {
"attribute": {
"data": [
{
"id": "25",
"type": "attribute",
"attributes": {
"product.lists.refid": "25",
"product.lists.domain": "attribute",
"product.lists.status": 1,
"product.lists.type": "variant"
}
},
{
"id": "28",
"type": "attribute",
"attributes": {
"product.lists.refid": "28",
"product.lists.domain": "attribute",
"product.lists.status": 1,
"product.lists.type": "variant"
}
}
]
}
}
}
the response will be the Product with the created Data
{
"meta": {
"total": 9
, "csrf": {
"name": "_token",
"value": ""
}
}
, "data": [
{
"id": "277",
"type": "product",
"attributes": {
"product.id": "277",
"product.siteid": "3.",
"product.ctime": "2020-12-04 15:43:38",
"product.mtime": "2020-12-04 15:43:38",
"product.editor": "shop2",
"product.url": "label-size-S-yellow",
"product.type": "default",
"product.code": "testselectioncreate-size-S-yellow",
"product.label": "label size S yellow",
"product.status": 1,
"product.dataset": "",
"product.datestart": null,
"product.dateend": null,
"product.config": [],
"product.scale": 1,
"product.target": "",
"product.rating": "0.00",
"product.ratings": 0
},
"links": {
},
"relationships": []
},
{
"type": "product",
"attributes": {
"product.status": 1,
"product.type": "default",
"product.label": "label size S yellow",
"product.code": "testselectioncreate-size-S-yellow"
},
"relationships": {
"attribute": {
"data": [
{
"id": "25",
"type": "attribute",
"attributes": {
"product.lists.refid": "25",
"product.lists.domain": "attribute",
"product.lists.status": 1,
"product.lists.type": "variant"
}
},
{
"id": "28",
"type": "attribute",
"attributes": {
"product.lists.refid": "28",
"product.lists.domain": "attribute",
"product.lists.status": 1,
"product.lists.type": "variant"
}
}
]
}
}
}
the response will be the Product with the created Data
{
"meta": {
"total": 9
, "csrf": {
"name": "_token",
"value": ""
}
}
, "data": [
{
"id": "277",
"type": "product",
"attributes": {
"product.id": "277",
"product.siteid": "3.",
"product.ctime": "2020-12-04 15:43:38",
"product.mtime": "2020-12-04 15:43:38",
"product.editor": "shop2",
"product.url": "label-size-S-yellow",
"product.type": "default",
"product.code": "testselectioncreate-size-S-yellow",
"product.label": "label size S yellow",
"product.status": 1,
"product.dataset": "",
"product.datestart": null,
"product.dateend": null,
"product.config": [],
"product.scale": 1,
"product.target": "",
"product.rating": "0.00",
"product.ratings": 0
},
"links": {
},
"relationships": []
},
Re: JSON API - create new product and add existing Attributes with Product.lists.type
when I check the source code in JSON ADM
As the line 432 the source code
$listItem = $listManager->createItem()->setType( 'default' );
I change to 'default' to 'variant' the variant is set for the product.lists.type
How could I extend the source here to get the product.lists.type from the request
As the line 432 the source code
$listItem = $listManager->createItem()->setType( 'default' );
I change to 'default' to 'variant' the variant is set for the product.lists.type
How could I extend the source here to get the product.lists.type from the request
Code: Select all
{
"type": "product",
"attributes": {
"product.status": 1,
"product.type": "default",
"product.label": "label size S yellow",
"product.code": "testselectioncreate-size-S-yellow"
},
"relationships": {
"attribute": {
"data": [
{
"id": "25",
"type": "attribute",
"attributes": {
"product.lists.refid": "25",
"product.lists.domain": "attribute",
"product.lists.status": 1,
"product.lists.type": "variant"
}
},
{
"id": "28",
"type": "attribute",
"attributes": {
"product.lists.refid": "28",
"product.lists.domain": "attribute",
"product.lists.status": 1,
"product.lists.type": "variant"
}
}
]
}
}
}
- Attachments
-
- Screen Shot 2020-12-04 at 4.44.17 PM.png (141.95 KiB) Viewed 9126 times
Re: JSON API - create new product and add existing Attributes with Product.lists.type
In line 437 (fromArray()), your product.lists.type should be set to "variant" if you pass that via the JsonAdm API. Can you please check what does happen there in your case?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

Re: JSON API - create new product and add existing Attributes with Product.lists.type
Thank you for your response,
However the product.lists.type is still "default"
could you please call an sample API fo checking it?
- create a new product with existing attributes and the product.lists.type: "variant"
However the product.lists.type is still "default"
could you please call an sample API fo checking it?
- create a new product with existing attributes and the product.lists.type: "variant"
Re: JSON API - create new product and add existing Attributes with Product.lists.type
as I am checking the In line 437 (fromArray()),
the $item is the product id rather than the product.list
I changed to this one and the product.lists is saved as expected:
would you like to check the source is it alright or any problems with my change?
Code: Select all
$item = $item->fromArray( $attr, true );
I changed to this one and the product.lists is saved as expected:
Code: Select all
$listItem = $listItem->fromArray( $attr, true );
Re: JSON API - create new product and add existing Attributes with Product.lists.type
Yes, it should be $listItem instead of $item. Can you create a PR for your fix?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

Re: JSON API - create new product and add existing Attributes with Product.lists.type
yes I already created a pull request
please help me check it
https://github.com/aimeos/ai-admin-json ... 11/commits
please help me check it
https://github.com/aimeos/ai-admin-json ... 11/commits
Re: JSON API - create new product and add existing Attributes with Product.lists.type
Thanks, your PR has been merged and will be part of the next release
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,
