商店用品;以编程方式设置产品封面
Shopware; setting the product-cover programmatically
我正在尝试以编程方式设置产品的封面,例如这样做;
[
"name" => "Example product"
"price" => [
0 => [
"currencyId" => "b7d2554b0ce847cd82f3ac9bd1c0dfca"
"gross" => 15
"net" => 10
"linked" => false
]
]
"manufacturer" => [
"name" => "Example manufacturer"
]
"tax" => [
"name" => "21%"
"taxRate" => 21
]
"stock" => 6235
"productNumber" => "PE-123123"
"coverId" => "4efd6bc156014cc2945b6351d3e9ff03"
]
我检查过,我确定媒体已上传。如果我通过如下所示的媒体进行操作,media/image 会正确链接。
"media" => [
"Id" => 'Example",
"mediaId" => "4efd6bc156014cc2945b6351d3e9ff03"
]
我不明白为什么会出错,因为文档 (https://docs.shopware.com/en/shopware-platform-dev-en/admin-api-guide/writing-entities#setting-the-cover) 是这样规定的。文档中的示例如下;
{
"name": "test",
"productNumber": "random",
"stock": 10,
"taxId": "5f78f2d4b19f49648eb1b38881463da0",
"price": [
{ "currencyId" : "b7d2554b0ce847cd82f3ac9bd1c0dfca", "gross": 15, "net": 10, "linked" : false }
],
"coverId": "00a9742db2e643ccb9d969f5a30c2758"
}
您应该按以下方式传递封面媒体 ID:
[
//other product data
"cover" => [
"mediaId" => "00a9742db2e643ccb9d969f5a30c2758"
]
]
对我来说,它有效。
"media": [
{
"id": 'YourProductUuid',
"media": {
"id": 'YourProductMediaId'
}
}
],
"cover" : {
"mediaId" : 'YourProductMediaId'
},
我正在尝试以编程方式设置产品的封面,例如这样做;
[
"name" => "Example product"
"price" => [
0 => [
"currencyId" => "b7d2554b0ce847cd82f3ac9bd1c0dfca"
"gross" => 15
"net" => 10
"linked" => false
]
]
"manufacturer" => [
"name" => "Example manufacturer"
]
"tax" => [
"name" => "21%"
"taxRate" => 21
]
"stock" => 6235
"productNumber" => "PE-123123"
"coverId" => "4efd6bc156014cc2945b6351d3e9ff03"
]
我检查过,我确定媒体已上传。如果我通过如下所示的媒体进行操作,media/image 会正确链接。
"media" => [
"Id" => 'Example",
"mediaId" => "4efd6bc156014cc2945b6351d3e9ff03"
]
我不明白为什么会出错,因为文档 (https://docs.shopware.com/en/shopware-platform-dev-en/admin-api-guide/writing-entities#setting-the-cover) 是这样规定的。文档中的示例如下;
{
"name": "test",
"productNumber": "random",
"stock": 10,
"taxId": "5f78f2d4b19f49648eb1b38881463da0",
"price": [
{ "currencyId" : "b7d2554b0ce847cd82f3ac9bd1c0dfca", "gross": 15, "net": 10, "linked" : false }
],
"coverId": "00a9742db2e643ccb9d969f5a30c2758"
}
您应该按以下方式传递封面媒体 ID:
[
//other product data
"cover" => [
"mediaId" => "00a9742db2e643ccb9d969f5a30c2758"
]
]
对我来说,它有效。
"media": [
{
"id": 'YourProductUuid',
"media": {
"id": 'YourProductMediaId'
}
}
],
"cover" : {
"mediaId" : 'YourProductMediaId'
},