Filter Group By or DISTINCT column
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!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
- IvanIgniter
- Posts: 58
- Joined: 01 Dec 2021, 07:41
Filter Group By or DISTINCT column
I am using laravel 6.x, PHP 7.4, Docker desktop/Ubuntu and the Aimeos 2021 (aimeos-laravel: 2021.10.4 / aimeos-core: 2021.10.13)
I have a question about model manager filtering in https://aimeos.org/docs/2021.x/models/search-filter/
I would like to know how can I make a filter like a group by or DISTINCT column name customerid in mshop_order_base table?
Please help..
I have a question about model manager filtering in https://aimeos.org/docs/2021.x/models/search-filter/
I would like to know how can I make a filter like a group by or DISTINCT column name customerid in mshop_order_base table?
Please help..
Re: Filter Group By or DISTINCT column
The order and order base manager implements the aggregate() method which you can use to group by keys, e.g.
The result will be an associative list of customer IDs and the number of orders per customer.
Code: Select all
$manager = \Aimeos\MShop::create( $this->context(), 'order/base' );
$filter = $manager->filter();
$result = $manager->aggregate( $filter, 'order.base.customerid' );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
- IvanIgniter
- Posts: 58
- Joined: 01 Dec 2021, 07:41
Re: Filter Group By or DISTINCT column
Thank you that was working but not as I wanted because it only return an array of customerid and qty it exist.
I would like to get the rows of orderbase those customerid have existed?
Is there a way to filter orderbase table based from the returned aggregated values?
I would like to get the rows of orderbase those customerid have existed?
Is there a way to filter orderbase table based from the returned aggregated values?
Re: Filter Group By or DISTINCT column
You have to use the found customer IDs to retrieve their orders afterwards using the search() method of the order/base manager.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
- IvanIgniter
- Posts: 58
- Joined: 01 Dec 2021, 07:41
Re: Filter Group By or DISTINCT column
Yap I found a way. Thank you.