同时更新所有语言的 customField

Update customField in all languages simultaneously

有没有办法同时更新自定义字段及其所有翻译?
现在代码看起来像这样(来自 cli 命令)

$context = Context::createDefaultContext();
$data = [[
    'id' => $productId,
    'customFields' => [
        'product_is_new' => true
    ]
]];
$this->productRepository->update($data, $context);

这只会更新主要语言的自定义字段,我想这是因为默认上下文。更新 customField 及其所有翻译的方式是什么?

您需要为每种语言提供 CustomFields。例如

$data = [
        'id' => $productId,
        'translations' => [
            'languageId1' => [
                'customFields' => [
                    'product_is_new' => true
                ]
            ],
            'languageId2' => [
                'customFields' => [
                    'product_is_new' => true
                ]
            ],
        ]
];
$this->productRepository->update($data, $context);