# Category Children NULL

**URL:** <https://forum.shopware.com/t/category-children-null/66919>\
**Category:** Allgemein\
**Created:** [13. Mai 2020 um 13:10 UTC](https://forum.shopware.com/t/category-children-null/66919 "2020-05-13T13:10:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dschott](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@dschott](https://forum.shopware.com/u/dschott)\
**Post date:** [13. Mai 2020 um 13:10 UTC](https://forum.shopware.com/t/category-children-null/66919/1 "2020-05-13T13:10:54Z")

</div>

Hallo, ich habe ein Problem mit den Categories. Und zwar sind die Children „NULL“, obwohl es welche gibt, die auch aktiv sind.

Meine Herangehensweise:  
Ich hole mir das Category Repo, führe ein „search“ durch mit einer Criteria auf „name“ mit dem Wert „Shop“. Ich bekomme eine Entity zurück, wo der Child Count richtig ist, aber die Children leer, wenn ich mit „$entity-\>getChildren()“ versuche, diese zu bekommen.

Es gab schonmal einen ähnlichen&nbsp;Beitrag hier im Forum, aber es scheint, dass die Codebasis verändert wurde:  
[https://forum.shopware.com/discussion/65072/shopware-6-menue-zeigt-nicht-alle-ebenen-an](https://forum.shopware.com/discussion/65072/shopware-6-menue-zeigt-nicht-alle-ebenen-an)

Ich hatte alternativ versucht, anhand der parentId die Children zu finden was auch funktioniert, aber dadurch wird die Sortierreihenfolge im Vergleich zur Kategoriestruktur verfälscht.

Ist das ein Bug mit den Children oder gibt es einfach eine andere Möglichkeit, an diese Werte zu kommen?

&nbsp;

```
 Shopware\Core\Content\Category\CategoryEntity Object ( [parentId:protected] =\> f0455b440fe9476ba51402ac78fc2f69 [autoIncrement:protected] =\> 2 [mediaId:protected] =\> [name:protected] =\> Shop [breadcrumb:protected] =\> Array ( [4c5710b98dbb4836a273fc3ddd3a1282] =\> Shop [f0455b440fe9476ba51402ac78fc2f69] =\> Main Navi ) [path:protected] =\> |f0455b440fe9476ba51402ac78fc2f69| [level:protected] =\> 2 [active:protected] =\> 1 [childCount:protected] =\> 11 [displayNestedProducts:protected] =\> 1 [parent:protected] =\> [children:protected] =\> [translations:protected] =\> [media:protected] =\> [products:protected] =\> [nestedProducts:protected] =\> [afterCategoryId:protected] =\> ... } 

```

&nbsp;

---

<div class="post-metadata">

**Author:** ![claudio](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@claudio](https://forum.shopware.com/u/claudio)\
**Post date:** [13. Mai 2020 um 22:56 UTC](https://forum.shopware.com/t/category-children-null/66919/2 "2020-05-13T22:56:18Z")

</div>

Vermutlich fehlt da ein&nbsp;

```
$criteria->addAssociation('children');

```

&nbsp;

---

<div class="post-metadata">

**Author:** ![dschott](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@dschott](https://forum.shopware.com/u/dschott)\
**Post date:** [14. Mai 2020 um 08:16 UTC](https://forum.shopware.com/t/category-children-null/66919/3 "2020-05-14T08:16:03Z")

</div>

Das wars, danke @claudio‍!

---

<div class="post-metadata">

**Author:** ![AlexBS](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@AlexBS](https://forum.shopware.com/u/AlexBS)\
**Post date:** [26. April 2022 um 19:21 UTC](https://forum.shopware.com/t/category-children-null/66919/4 "2022-04-26T19:21:40Z")

</div>

> [@claudio](#):
>
> $criteria-\>addAssociation(‚children‘);

Der Thread ist zwar schon alt, aber darf ich fragen, woher du den SalesChannelContext herbekommst, den man für das search() auf das Category Repo braucht? Danke und lg Alex

**EDIT: Habe es schon lösen können.**

---

<div class="post-metadata">

**Author:** ![andrea](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@andrea](https://forum.shopware.com/u/andrea)\
**Post date:** [23. Juli 2022 um 09:19 UTC](https://forum.shopware.com/t/category-children-null/66919/5 "2022-07-23T09:19:49Z")

</div>

Please, can you indicate where to add this instruction? Which file?
