Page 1 of 1

Catalog tree

Posted: 02 Sep 2016, 14:13
by earosb
Hi there!

I have a catalog tree that i created from backend admin, I need to show the same tree in frontend but when i search all categories the hasChildren function always return false. This is part of my code

Code: Select all

$manager = \Aimeos\MShop\Factory::createManager( $context, 'catalog' );
$search = $manager->createSearch();
$categories = $manager->searchItems($search);

foreach ($categories as $category) {
    if ( $category->hasChildren() ) {
        // code stuff...
    }
}
I'm using typo3 7.6.10, extbase and Aimeos 16.4.3

Thanks in advance

Re: Catalog tree

Posted: 02 Sep 2016, 14:18
by aimeos
Well single items returned by searchItems() don't have children. Use the getTree() method of the catalog manager instead to get a tree of nodes instead.

Re: Catalog tree

Posted: 02 Sep 2016, 18:59
by earosb
aimeos wrote:Well single items returned by searchItems() don't have children. Use the getTree() method of the catalog manager instead to get a tree of nodes instead.
Thank you Mr. Aimeos, you are a genius!