在Shopware 6中创建新类别6获取错误/0/Translations/2FBB5FE2E29A4D70AA5854CE7CE3E20B/name
尝试创建一个新类别时,我会得到此错误。
/0/translations/2fbb5fe2e29a4d70aa5854ce7ce3e20b/name This value should not be blank.
这是我的数组:(如您所见。我的错误与密钥的名称有关。但是钥匙的名称具有值),
[
0 => [
"categories" => [
"id" => "7767b163a5124c83ad8f6c701ffabade",
"parentId" => null,
"name" => "Supply",
"path" => "professional",
"level" => 5,
"active" => true,
"description" => null,
"translations" => [
"2fbb5fe2e29a4d70aa5854ce7ce3e20b" =>[
"defaultLanguageId"=>"2fbb5fe2e29a4d70aa5854ce7ce3e20b",
"name" => "Professional",
"metaTitle" => "",
"metaDescription" => "",
"description" => "",
],
"f7e5c2a4bb194c339714f9798d8f853d" => [
"name" => "Materiale Profession",
"defaultLanguageId"=>"2fbb5fe2e29a4d70aa5854ce7ce3e20b",
"metaTitle" => "",
"metaDescription" => "",
"description" => "",
],
"51d36b57c6144235bcb0332a3ca20a5c" => [
"name" => "Profesional",
"defaultLanguageId"=>"2fbb5fe2e29a4d70aa5854ce7ce3e20b",
"metaTitle" => "",
"metaDescription" => "",
"description" => "",
],
"66623e62998e42c695fba0d22b023c63" =>[
"name" => "Professionnel",
"defaultLanguageId"=>"2fbb5fe2e29a4d70aa5854ce7ce3e20b",
"metaTitle" => "",
"metaDescription" => "",
"description" => "",
],
]
]
]]
而且,如果没有翻译,它也无法使用。 我没有创建产品的问题。
$this->productRepository->create($products, $context);
仅当我要创建类别时,我才会得到这个错误
$this->categoryRepository->create($category, $context);
吗?有人知道我的问题在哪里吗?
When trying to create a new category, I get this error.
/0/translations/2fbb5fe2e29a4d70aa5854ce7ce3e20b/name This value should not be blank.
This is my array:(As you can see. My error is related to the key's name. But the key's name has a value)
[
0 => [
"categories" => [
"id" => "7767b163a5124c83ad8f6c701ffabade",
"parentId" => null,
"name" => "Supply",
"path" => "professional",
"level" => 5,
"active" => true,
"description" => null,
"translations" => [
"2fbb5fe2e29a4d70aa5854ce7ce3e20b" =>[
"defaultLanguageId"=>"2fbb5fe2e29a4d70aa5854ce7ce3e20b",
"name" => "Professional",
"metaTitle" => "",
"metaDescription" => "",
"description" => "",
],
"f7e5c2a4bb194c339714f9798d8f853d" => [
"name" => "Materiale Profession",
"defaultLanguageId"=>"2fbb5fe2e29a4d70aa5854ce7ce3e20b",
"metaTitle" => "",
"metaDescription" => "",
"description" => "",
],
"51d36b57c6144235bcb0332a3ca20a5c" => [
"name" => "Profesional",
"defaultLanguageId"=>"2fbb5fe2e29a4d70aa5854ce7ce3e20b",
"metaTitle" => "",
"metaDescription" => "",
"description" => "",
],
"66623e62998e42c695fba0d22b023c63" =>[
"name" => "Professionnel",
"defaultLanguageId"=>"2fbb5fe2e29a4d70aa5854ce7ce3e20b",
"metaTitle" => "",
"metaDescription" => "",
"description" => "",
],
]
]
]]
Also, it doesn't work without translation.
I don't have a problem with creating products.
$this->productRepository->create($products, $context);
I get this error only when I'm going to create the category
$this->categoryRepository->create($category, $context);
Does anyone know where my problem is?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为错误的原因是示例中的额外
类别
数组键。存储库期望与实体的字段作为密钥的字段列表,这意味着在您的示例中,您仅提供类别
字段,这是没有有效的类别有效负载。此外,在您的情况下,您可以大大简化代码,因为您似乎只想以不同的语言更新名称。
您可以尝试以下有效载荷:
注意丢失的数组索引
类别
。I think the reason for the error is the extra
categories
array key in your example. The repository expects a list of associative arrays with the fields of the entities as keys, that means in your example you only provide thecategories
field, which is no valid category payload.Additionally in your case you could greatly simplify your code as it seems that you only want to update the name in different languages.
You can try the following payload:
Notice the missing array index
categories
.