Hi, I’ve stumbled upon the same issue as found by some other developers in the past and the solution which was found common was to create a fake root node. The first link is from the exertion issues. The issue suggests it is solved but I can’t work on it. The data entry is as follows.
<?php
$fruits = new Category();
$fruits->setTitle('Fruits');
$fruits->setParent($food);
$vegetables = new Category();
$vegetables->setTitle('Vegetables');
$vegetables->setParent($food);
$carrots = new Category();
$carrots->setTitle('Carrots');
$carrots->setParent($vegetables);
$homeappliences = new Category();
$homeappliences->setTitle('Home Appliences');
$microwave = new Category();
$microwave->setTitle('Microwave oven');
$microwave->setParent($homeappliences);
$this->entityManager->persist($food);
$this->entityManager->persist($fruits);
$this->entityManager->persist($vegetables);
$this->entityManager->persist($carrots);
$this->entityManager->persist($homeappliences);
$this->entityManager->persist($microwave);
$this->entityManager->flush();
$repo = $this->entityManager->getRepository(Category::class);
$repo->reorder();
// Below line throws error: Invalid sort options specified: field - tree_root, direction - ASC
// Un-comment to see the error.
// $repo->reorder(null, 'tree_root');
Thanks!