gpt4 book ai didi

api - Shopware 6 通过 store-api 获取父产品

转载 作者:行者123 更新时间:2023-12-05 09:32:12 30 4
gpt4 key购买 nike

我正在尝试使用商店 API 获取特定产品的父项。
当我添加 parent 关联时,我收到错误代码 FRAMEWORK__PARENT_ASSOCIATION_CAN_NOT_BE_FETCHED

我的请求是这样的: enter image description here

我真的必须使用 parentId 进行第二次请求来获取一些父产品信息还是有其他方法?

最佳答案

您可以尝试搜索子项 ID 为“xyz”的产品,而不是尝试查找一个变体的父项。 Shopware 支持过滤嵌套对象,例如“children.id”。

例如:

POST /store-api/product
Content-Type: application/json
Accept: application/json
sw-access-key: ...
sw-language-id: ...

{
"includes": {
"product": ["productNumber", "children", "name", "translated.name"]
},
"associations": {
"children": []
},
"filter": [
{"field": "children.id", "type": "equals", "value": "f87a875bc5fa47e08ea40a19ce9c5627"}
]
}

应该给你父子输出:

{
"entity": "product",
"total": 1,
"aggregations": [],
"page": 1,
"limit": null,
"elements": [
{
"productNumber": "252009 00-0002",
"name": null,
"children": [
{
"productNumber": "252009 00-0002.3",
"name": null,
"children": null,
"translated": {
"name": "T-Shirt Logo"
},
"apiAlias": "product"
},
{
"productNumber": "252009 00-0002.1",
"name": null,
"children": null,
"translated": {
"name": "T-Shirt Logo"
},
"apiAlias": "product"
},
{
"productNumber": "252009 00-0002.4",
"name": null,
"children": null,
"translated": {
"name": "T-Shirt Logo"
},
"apiAlias": "product"
},
{
"productNumber": "252009 00-0002.2",
"name": null,
"children": null,
"translated": {
"name": "T-Shirt Logo"
},
"apiAlias": "product"
}
],
"translated": {
"name": "T-Shirt Logo"
},
"apiAlias": "product"
}
],
"apiAlias": "dal_entity_search_result"
}

关于api - Shopware 6 通过 store-api 获取父产品,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68360059/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com