Joins Queries

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!
jramirezgranada
Posts: 40
Joined: 12 Jul 2018, 19:57

Joins Queries

Post by jramirezgranada » 06 May 2019, 18:54

Hi there;

Is there a way to get users with an associated customer group? or is there a way to do joins queries?

I need to do something like this but with managers

Code: Select all

select * from users as u inner join users_list ul on u.id = ul.parentid join mshop_customer_group mcg on cast(ul.refid as integer) = mcg.id
Thanks
--
Jorge A Ramirez
System Engineer
PHP Developer

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

Re: Joins Queries

Post by aimeos » 07 May 2019, 08:30

Easy going: Use "customer/group" for the list of domain names to fetch in getItem(), findItem() or searchItems(), e.g.:

Code: Select all

$customerItem = $manager->getItem( 123, ["customer/group"] );
$groupItems = $customerItem->getRefItems( "customer/group" );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

jramirezgranada
Posts: 40
Joined: 12 Jul 2018, 19:57

Re: Joins Queries

Post by jramirezgranada » 07 May 2019, 14:07

Yes, I've worked in that way, and it returns all users even if they don't have an assigned customer group. I want to get only users with an assigned customer group.
--
Jorge A Ramirez
System Engineer
PHP Developer

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

Re: Joins Queries

Post by aimeos » 07 May 2019, 15:54

When you've installed 2019.04, you can use the "customer:has" search function:

Code: Select all

$search = $manager->createSearch();
$func = $search->createFunction( 'customer:has', ['customer/group'] );
$search->setConditions( $search->compare( '!=', $func, null ) );
$items = $manager->searchItems( $search );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

jramirezgranada
Posts: 40
Joined: 12 Jul 2018, 19:57

Re: Joins Queries

Post by jramirezgranada » 07 May 2019, 16:25

Thanks, for previous version is not there a way to do that ?
--
Jorge A Ramirez
System Engineer
PHP Developer

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

Re: Joins Queries

Post by aimeos » 08 May 2019, 07:50

Not really the same, you can only search for customers that contain a specific user group by its ID with "customer:has". The only alternative is a low level query and feeding the result into the customer manager but that requires in total two queries instead of one.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply