shopware - 同时更新所有语言的 customField
问题描述
有没有办法同时更新 customField 及其所有翻译?
现在代码看起来像这样(来自 cli 命令)
$context = Context::createDefaultContext();
$data = [[
'id' => $productId,
'customFields' => [
'product_is_new' => true
]
]];
$this->productRepository->update($data, $context);
这只会更新主要语言中的自定义字段,我想这是因为默认上下文。更新 customField 及其所有翻译的方法是什么?
解决方案
您需要为每种语言提供自定义字段。例如
$data = [
'id' => $productId,
'translations' => [
'languageId1' => [
'customFields' => [
'product_is_new' => true
]
],
'languageId2' => [
'customFields' => [
'product_is_new' => true
]
],
]
];
$this->productRepository->update($data, $context);
推荐阅读
- c# - 可以在 C# 的 HtmlAgilityPack 中使用 LINQ 吗?
- c# - 随机选择卡片
- c++ - 如何等到池中的所有线程结束工作?
- python - 使用正则表达式提取列的一部分或在 python 中拆分
- python - ValueError:无法解释输入“评级”
- javascript - 使用 Axios 的 HTTP 请求
- python - 获取具有条件的值的总和
- forms - Symfony 4 表单 - 如何在子表单中获取父级的子元素
- twitter - twitter 流 API 是否允许通过 url 过滤?
- node.js - 在 React 应用程序中导入“vscode-languageserver”时出错