Filter by customer group in admin panel

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!
Gagik
Posts: 43
Joined: 05 Dec 2023, 06:58

Filter by customer group in admin panel

Post by Gagik » 28 Mar 2025, 11:50

Hi.
In this article I found a solution for this case. https://aimeos.org/help/viewtopic.php?f ... 949#p24949
Advice for it is use 'customer:has("group","default",<id>)'
But I don't know how to use it. Below is my code for search. Is available any code example or something else ?

$total = 0;
$params = $this->storeFilter( $view->param(), 'customer' );

$manager = \Aimeos\MShop::create( $this->context(), 'customer' );
$search = $this->initCriteria( $manager->filter(), $params );

$view->items = $manager->search( $search, $this->getDomains(), $total );
$view->filterAttributes = $manager->getSearchAttributes( true );
$view->filterOperators = $search->getOperators();
$view->itemBody = parent::search();
$view->total = $total;

Gagik
Posts: 43
Joined: 05 Dec 2023, 06:58

Re: Filter by customer group in admin panel

Post by Gagik » 28 Mar 2025, 14:24

I tried by this way but it didn't help

$manager = \Aimeos\MShop::create( $this->context(), 'customer' );
$search = $this->initCriteria( $manager->filter(), $params );
$func = $search->make( 'customer:has', ['group', 'default', 1] );
$expr = array(
$search->compare( '!=', $func, null ),
);
$search->setConditions( $search->and( $expr ) );
$view->items = $manager->search( $search, $this->getDomains(), $total );

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

Re: Filter by customer group in admin panel

Post by aimeos » 29 Mar 2025, 14:03

This should work and filter for customers having group "1" associated:

Code: Select all

$manager = \Aimeos\MShop::create( $this->context(), 'customer' );
$search = $this->initCriteria( $manager->filter(), $params );
$search->add( $search->make( 'customer:has', ['group', 'default', '1'] ), '!=', null );
$view->items = $manager->search( $search, $this->getDomains(), $total );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Gagik
Posts: 43
Joined: 05 Dec 2023, 06:58

Re: Filter by customer group in admin panel

Post by Gagik » 31 Mar 2025, 08:14

Your given solution always gives an empty result. But I can't know why. Maybe reason is a version ? Project Aimeos version is 2023.07

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

Re: Filter by customer group in admin panel

Post by aimeos » 01 Apr 2025, 08:10

In 2023.10, the domain is "customer/group" instead of "group":

Code: Select all

$manager = \Aimeos\MShop::create( $this->context(), 'customer' );
$search = $this->initCriteria( $manager->filter(), $params );
$search->add( $search->make( 'customer:has', ['customer/group', 'default', '1'] ), '!=', null );
$view->items = $manager->search( $search, $this->getDomains(), $total );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Gagik
Posts: 43
Joined: 05 Dec 2023, 06:58

Re: Filter by customer group in admin panel

Post by Gagik » 01 Apr 2025, 11:57

Great. Thanks.

Post Reply