How to group favorite items by category?

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
columbo
Advanced
Posts: 125
Joined: 09 Oct 2019, 09:42

How to group favorite items by category?

Post by columbo » 26 Feb 2024, 15:13

Hi,

our customers have many favorites, 400 items and more.
To make the list a little clearer, we'd like to group favorites in categories (as in the default catalog).

category A
- item 1
- item 2

category B
- item x
...

Do you have a recommendation on how this can be done?
I expect to adapt the query to group by category but I couldn't get it to work:
https://github.com/aimeos/ai-client-htm ... #L220-L224

Or should all be done in the template?
https://github.com/aimeos/ai-client-htm ... e/body.php

Thank you

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

Re: How to group favorite items by category?

Post by aimeos » 27 Feb 2024, 10:48

You can not get the products already grouped by the categories from search() method of the manager for several reasons. Best is to do group the products in the template using the groupBy() method from the Map package with a Closure that cares about retrieving the information for grouping:
https://php-map.org/#groupby
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply