在Shopware 6中创建新类别6获取错误/0/Translations/2FBB5FE2E29A4D70AA5854CE7CE3E20B/name

发布于 2025-01-24 09:49:18 字数 1857 浏览 5 评论 0原文

尝试创建一个新类别时,我会得到此错误。

/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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

↘人皮目录ツ 2025-01-31 09:49:19

我认为错误的原因是示例中的额外类别数组键。存储库期望与实体的字段作为密钥的字段列表,这意味着在您的示例中,您仅提供类别字段,这是没有有效的类别有效负载。

此外,在您的情况下,您可以大大简化代码,因为您似乎只想以不同的语言更新名称。

您可以尝试以下有效载荷:

[
  0 => [
    "id" => "7767b163a5124c83ad8f6c701ffabade",
    "parentId" => null,
    "name" => [
      "2fbb5fe2e29a4d70aa5854ce7ce3e20b" => "Professional",
      "f7e5c2a4bb194c339714f9798d8f853d" => "Materiale Profession",
        ...
    ],
    "path" => "professional",
    "level" => 5,
    "active" => true,
    "description" => null,
  ]
]

注意丢失的数组索引类别

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 the categories 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:

[
  0 => [
    "id" => "7767b163a5124c83ad8f6c701ffabade",
    "parentId" => null,
    "name" => [
      "2fbb5fe2e29a4d70aa5854ce7ce3e20b" => "Professional",
      "f7e5c2a4bb194c339714f9798d8f853d" => "Materiale Profession",
        ...
    ],
    "path" => "professional",
    "level" => 5,
    "active" => true,
    "description" => null,
  ]
]

Notice the missing array index categories.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文