I'm using this particular code from the example (returns 12):
private static function printAccountHierarchy($account,
$customerIdsToAccounts, $customerIdsToChildLinks, $depth = null) {
if ($depth === null) {
print "(Customer ID, Account Name)<br>";
self::printAccountHierarchy(
$account, $customerIdsToAccounts, $customerIdsToChildLinks, 0);
return;
}
print str_repeat('-', $depth * 2);
$customerId = $account->getCustomerId();
printf("%s, %s<br>", $customerId, $account->getName());
if (array_key_exists($customerId, $customerIdsToChildLinks)) {
foreach ($customerIdsToChildLinks[$customerId] as $childLink) {
$childAccount =
$customerIdsToAccounts[$childLink->getClientCustomerId()];
self::printAccountHierarchy($childAccount, $customerIdsToAccounts,
$customerIdsToChildLinks, $depth + 1);
}
}
}
But if I try to use this plain code to display accounts, it will return 31 accounts.
foreach ($customerIdsToAccounts as $account) {
echo $account->getName() . '
';
}
What did I missed here? Thanks