Cannot get the full tree of the categories using getTree

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Robert
Posts: 3
Joined: 25 Jun 2019, 08:22

Cannot get the full tree of the categories using getTree

Post by Robert » 25 Jun 2019, 09:04

Hello,

I have 3 level of categories. Root -> Lvl1 -> Lvl2 -> Lvl3

I have a problem getting the full tree of the categories to display in the client. Although I selected LEVEL_TREE both in the config and even tried it in a custom part as seen in the snippet code bellow, the function and the framework only returns the children of the root category provided.

This seems to be a bug in the getTree( ) function because I can only get the children of the start category no matter the category starting point.

Also to mention in the client area: If I select a category I immediately get their children, and the if I select a child, I get their children, but not by default.

Any ideas as to why is this behavior?

Code: Select all

$ref = $view->config( 'client/html/catalog/filter/tree/domains', array( 'text', 'media') );
$context = $this->getContext();
$controller = \Aimeos\Controller\Frontend\Factory::createController( $context, 'catalog' );
    
$catItems = $controller->getTree( null, $ref, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE );
Thank you!
Attachments
The full nodes with children shows only when I select the last category. Why?
The full nodes with children shows only when I select the last category. Why?
Screenshot 2019-06-25 at 11.52.02.png (142.65 KiB) Viewed 1756 times

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Cannot get the full tree of the categories using getTree

Post by aimeos » 25 Jun 2019, 16:03

Guess, you are using Aimeos 2018.10.
The catalog/filter/tree component limits the shown category to those which are visible by default, so you don't get back the whole tree: https://github.com/aimeos/ai-client-htm ... d.php#L312

You can overwrite that method in your own class to get all nodes if you want to show hide them by Javascript. Might be also possible to add a configuration option to do this if you want to get this into the core and create a PR :-)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Robert
Posts: 3
Joined: 25 Jun 2019, 08:22

Re: Cannot get the full tree of the categories using getTree

Post by Robert » 27 Jun 2019, 12:18

Thanks for the reply!

Can I upgrade to 2019 without breaking the current functionality?
I have a Laravel implementation.

Update:
I have some custom pages, and apparently in 2019 this : app( '\Aimeos\Shop\Base\Page' )->getSections( 'basic' );
no longer works (Class \Aimeos\Shop\Base\Page does not exist).
Where is the documentation for 2019? It seems the official one is not updated to the latest version?

How to you get sections in 2019 for custom pages?

I have used this: https://aimeos.org/docs/Laravel/Create_new_pages

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Cannot get the full tree of the categories using getTree

Post by aimeos » 27 Jun 2019, 15:32

Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Robert
Posts: 3
Joined: 25 Jun 2019, 08:22

Re: Cannot get the full tree of the categories using getTree

Post by Robert » 27 Jun 2019, 18:38

Missed it.

Thank you!

Post Reply