new TermsAggregation('category-ids', 'parentId', null, null,
new CountAggregation('visible-children-count', 'id'
)) );
$termsResult =
$this->categoryRepository
->
aggregate($criteria,
$context) ->
get('category-ids'
);
if (!
($termsResult instanceof TermsResult
)) { return;
} foreach ($termsResult->
getBuckets() as $bucket) { $key =
$bucket->
getKey();
if ($key === null
) { continue;
} $parent =
$levels->
get($key);
if ($parent instanceof CategoryEntity
) { $parent->
setVisibleChildCount($bucket->
getCount());
} }