Ezpublish::getGroupSql()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 2
dl 0
loc 13
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2016-2020
6
 * @package MShop
7
 * @subpackage Customer
8
 */
9
10
11
namespace Aimeos\MShop\Customer\Manager;
12
13
14
/**
15
 * Customer class implementation for ezPublish
16
 *
17
 * @package MShop
18
 * @subpackage Customer
19
 */
20
class Ezpublish
21
	extends \Aimeos\MShop\Customer\Manager\Standard
22
{
23
	private $searchConfig = array(
24
		'customer.id' => array(
25
			'label' => 'Customer ID',
26
			'code' => 'customer.id',
27
			'internalcode' => 'ezu."contentobject_id"',
28
			'type' => 'integer',
29
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT
30
		),
31
		// customer.siteid is not available
32
		'customer.label' => array(
33
			'label' => 'Customer label',
34
			'code' => 'customer.label',
35
			'internalcode' => 'ezu."login"',
36
			'type' => 'string',
37
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR
38
		),
39
		'customer.code' => array(
40
			'label' => 'Customer username',
41
			'code' => 'customer.code',
42
			'internalcode' => 'ezu."login_normalized"',
43
			'type' => 'string',
44
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR
45
		),
46
		'customer.salutation' => array(
47
			'label' => 'Customer salutation',
48
			'code' => 'customer.salutation',
49
			'internalcode' => 'ezu."salutation"',
50
			'type' => 'string',
51
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
52
		),
53
		'customer.company'=> array(
54
			'label' => 'Customer company',
55
			'code' => 'customer.company',
56
			'internalcode' => 'ezu."company"',
57
			'type' => 'string',
58
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
59
		),
60
		'customer.vatid'=> array(
61
			'label' => 'Customer VAT ID',
62
			'code' => 'customer.vatid',
63
			'internalcode' => 'ezu."vatid"',
64
			'type' => 'string',
65
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
66
		),
67
		'customer.title' => array(
68
			'label' => 'Customer title',
69
			'code' => 'customer.title',
70
			'internalcode' => 'ezu."title"',
71
			'type' => 'string',
72
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
73
		),
74
		'customer.firstname' => array(
75
			'label' => 'Customer firstname',
76
			'code' => 'customer.firstname',
77
			'internalcode' => 'ezu."firstname"',
78
			'type' => 'string',
79
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
80
		),
81
		'customer.lastname' => array(
82
			'label' => 'Customer lastname',
83
			'code' => 'customer.lastname',
84
			'internalcode' => 'ezu."lastname"',
85
			'type' => 'string',
86
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
87
		),
88
		'customer.address1' => array(
89
			'label' => 'Customer address part one',
90
			'code' => 'customer.address1',
91
			'internalcode' => 'ezu."address1"',
92
			'type' => 'string',
93
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
94
		),
95
		'customer.address2' => array(
96
			'label' => 'Customer address part two',
97
			'code' => 'customer.address2',
98
			'internalcode' => 'ezu."address2"',
99
			'type' => 'string',
100
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
101
		),
102
		'customer.address3' => array(
103
			'label' => 'Customer address part three',
104
			'code' => 'customer.address3',
105
			'internalcode' => 'ezu."address3"',
106
			'type' => 'string',
107
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
108
		),
109
		'customer.postal' => array(
110
			'label' => 'Customer postal',
111
			'code' => 'customer.postal',
112
			'internalcode' => 'ezu."postal"',
113
			'type' => 'string',
114
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
115
		),
116
		'customer.city' => array(
117
			'label' => 'Customer city',
118
			'code' => 'customer.city',
119
			'internalcode' => 'ezu."city"',
120
			'type' => 'string',
121
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
122
		),
123
		'customer.state' => array(
124
			'label' => 'Customer state',
125
			'code' => 'customer.state',
126
			'internalcode' => 'ezu."state"',
127
			'type' => 'string',
128
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
129
		),
130
		'customer.languageid' => array(
131
			'label' => 'Customer language',
132
			'code' => 'customer.languageid',
133
			'internalcode' => 'ezu."langid"',
134
			'type' => 'string',
135
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
136
		),
137
		'customer.countryid' => array(
138
			'label' => 'Customer country',
139
			'code' => 'customer.countryid',
140
			'internalcode' => 'ezu."countryid"',
141
			'type' => 'string',
142
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
143
		),
144
		'customer.telephone' => array(
145
			'label' => 'Customer telephone',
146
			'code' => 'customer.telephone',
147
			'internalcode' => 'ezu."telephone"',
148
			'type' => 'string',
149
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
150
		),
151
		'customer.email' => array(
152
			'label' => 'Customer email',
153
			'code' => 'customer.email',
154
			'internalcode' => 'ezu."email"',
155
			'type' => 'string',
156
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
157
		),
158
		'customer.telefax' => array(
159
			'label' => 'Customer telefax',
160
			'code' => 'customer.telefax',
161
			'internalcode' => 'ezu."telefax"',
162
			'type' => 'string',
163
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
164
		),
165
		'customer.website' => array(
166
			'label' => 'Customer website',
167
			'code' => 'customer.website',
168
			'internalcode' => 'ezu."website"',
169
			'type' => 'string',
170
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
171
		),
172
		'customer.birthday' => array(
173
			'label' => 'Customer birthday',
174
			'code' => 'customer.birthday',
175
			'internalcode' => 'ezu."birthday"',
176
			'type' => 'string',
177
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
178
		),
179
		'customer.password'=> array(
180
			'label' => 'Customer password',
181
			'code' => 'customer.password',
182
			'internalcode' => 'ezu."password_hash"',
183
			'type' => 'string',
184
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
185
		),
186
		'customer.status'=> array(
187
			'label' => 'Customer status',
188
			'code' => 'customer.status',
189
			'internalcode' => 'ezs."is_enabled"',
190
			'type' => 'integer',
191
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT
192
		),
193
		'customer.dateverified'=> array(
194
			'label' => 'Customer verification date',
195
			'code' => 'customer.dateverified',
196
			'internalcode' => 'ezu."vdate"',
197
			'type' => 'date',
198
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
199
		),
200
		'customer.ctime'=> array(
201
			'label' => 'Customer creation time',
202
			'code' => 'customer.ctime',
203
			'internalcode' => 'ezu."ctime"',
204
			'type' => 'datetime',
205
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
206
		),
207
		'customer.mtime'=> array(
208
			'label' => 'Customer modification time',
209
			'code' => 'customer.mtime',
210
			'internalcode' => 'ezu."mtime"',
211
			'type' => 'datetime',
212
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
213
		),
214
		'customer.editor'=> array(
215
			'label'=>'Customer editor',
216
			'code'=>'customer.editor',
217
			'internalcode' => 'ezu."editor"',
218
			'type'=> 'string',
219
			'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR,
220
		),
221
		'customer:has' => array(
222
			'code' => 'customer:has()',
223
			'internalcode' => ':site AND :key AND ezuli."id"',
224
			'internaldeps' => ['LEFT JOIN "ezuser_list" AS ezuli ON ( ezuli."parentid" = ezu."id" )'],
225
			'label' => 'Customer has list item, parameter(<domain>[,<list type>[,<reference ID>)]]',
226
			'type' => 'null',
227
			'internaltype' => 'null',
228
			'public' => false,
229
		),
230
		'customer:prop' => array(
231
			'code' => 'customer:prop()',
232
			'internalcode' => ':site AND :key AND ezupr."id"',
233
			'internaldeps' => ['LEFT JOIN "ezuser_property" AS ezupr ON ( ezupr."parentid" = ezu."id" )'],
234
			'label' => 'Customer has property item, parameter(<property type>[,<language code>[,<property value>]])',
235
			'type' => 'null',
236
			'internaltype' => 'null',
237
			'public' => false,
238
		),
239
	);
240
241
242
	/**
243
	 * Initializes the object.
244
	 *
245
	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
246
	 */
247
	public function __construct( \Aimeos\MShop\Context\Item\Iface $context )
248
	{
249
		parent::__construct( $context );
250
251
		$level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL;
252
		$level = $context->getConfig()->get( 'mshop/customer/manager/sitemode', $level );
253
254
255
		$this->searchConfig['customer:has']['function'] = function( &$source, array $params ) use ( $level ) {
256
257
			array_walk_recursive( $params, function( &$v ) {
258
				$v = trim( $v, '\'' );
259
			} );
260
261
			$keys = [];
262
			$params[1] = isset( $params[1] ) ? $params[1] : '';
263
			$params[2] = isset( $params[2] ) ? $params[2] : '';
264
265
			foreach( (array) $params[1] as $type ) {
266
				foreach( (array) $params[2] as $id ) {
267
					$keys[] = $params[0] . '|' . ( $type ? $type . '|' : '' ) . $id;
268
				}
269
			}
270
271
			$sitestr = $this->getSiteString( 'ezuli."siteid"', $level );
272
			$keystr = $this->toExpression( 'ezuli."key"', $keys, $params[2] !== '' ? '==' : '=~' );
273
			$source = str_replace( [':site', ':key'], [$sitestr, $keystr], $source );
274
275
			return $params;
276
		};
277
278
279
		$this->searchConfig['customer:prop']['function'] = function( &$source, array $params ) use ( $level ) {
280
281
			array_walk_recursive( $params, function( &$v ) {
282
				$v = trim( $v, '\'' );
283
			} );
284
285
			$keys = [];
286
			$params[1] = array_key_exists( 1, $params ) ? $params[1] : '';
287
			$params[2] = isset( $params[2] ) ? $params[2] : '';
288
289
			foreach( (array) $params[1] as $lang ) {
290
				foreach( (array) $params[2] as $id ) {
291
					$keys[] = $params[0] . '|' . ( $lang ? $lang . '|' : '' ) . ( $id !== '' ?  md5( $id ) : '' );
292
				}
293
			}
294
295
			$sitestr = $this->getSiteString( 'ezupr."siteid"', $level );
296
			$keystr = $this->toExpression( 'ezupr."key"', $keys, $params[2] !== '' ? '==' : '=~' );
297
			$source = str_replace( [':site', ':key'], [$sitestr, $keystr], $source );
298
299
			return $params;
300
		};
301
	}
302
303
304
	/**
305
	 * Removes old entries from the storage.
306
	 *
307
	 * @param string[] $siteids List of IDs for sites whose entries should be deleted
308
	 * @return \Aimeos\MShop\Common\Manager\Iface Same object for fluent interface
309
	 */
310
	public function clear( array $siteids ) : \Aimeos\MShop\Common\Manager\Iface
311
	{
312
		$path = 'mshop/customer/manager/submanagers';
313
		foreach( $this->getContext()->getConfig()->get( $path, ['address', 'group', 'lists', 'property'] ) as $domain ) {
314
			$this->getObject()->getSubManager( $domain )->clear( $siteids );
315
		}
316
317
		return $this;
318
	}
319
320
321
	/**
322
	 * Removes multiple items.
323
	 *
324
	 * @param \Aimeos\MShop\Common\Item\Iface[]|string[] $itemIds List of item objects or IDs of the items
325
	 * @return \Aimeos\MShop\Common\Manager\Iface Manager object for chaining method calls
326
	 */
327
	public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
328
	{
329
		$service = $this->getContext()->getEzUserService();
0 ignored issues
show
Bug introduced by
The method getEzUserService() does not exist on Aimeos\MShop\Context\Item\Iface. It seems like you code against a sub-type of Aimeos\MShop\Context\Item\Iface such as Aimeos\MShop\Context\Item\Ezpublish. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

329
		$service = $this->getContext()->/** @scrutinizer ignore-call */ getEzUserService();
Loading history...
330
331
		foreach( $itemIds as $id ) {
332
			$service->deleteUser( $service->loadUser( (string) $id ) );
333
		}
334
335
		return $this->deleteRefItems( $itemIds );
336
	}
337
338
339
	/**
340
	 * Returns the list attributes that can be used for searching.
341
	 *
342
	 * @param bool $withsub Return also attributes of sub-managers if true
343
	 * @return array List of attribute items implementing \Aimeos\MW\Criteria\Attribute\Iface
344
	 */
345
	public function getSearchAttributes( bool $withsub = true ) : array
346
	{
347
		$path = 'mshop/customer/manager/submanagers';
348
349
		return $this->getSearchAttributesBase( $this->searchConfig, $path, ['address', 'group', 'lists', 'property'], $withsub );
350
	}
351
352
353
	/**
354
	 * Returns a new manager for customer extensions
355
	 *
356
	 * @param string $manager Name of the sub manager type in lower case
357
	 * @param string|null $name Name of the implementation, will be from configuration (or Default) if null
358
	 * @return \Aimeos\MShop\Common\Manager\Iface Manager for different extensions, e.g stock, tags, locations, etc.
359
	 */
360
	public function getSubManager( string $manager, string $name = null ) : \Aimeos\MShop\Common\Manager\Iface
361
	{
362
		return $this->getSubManagerBase( 'customer', $manager, ( $name === null ? 'Ezpublish' : $name ) );
363
	}
364
365
366
	/**
367
	 * Saves a customer item object.
368
	 *
369
	 * @param \Aimeos\MShop\Customer\Item\Iface $item Customer item object
370
	 * @param bool $fetch True if the new ID should be returned in the item
371
	 * @return \Aimeos\MShop\Customer\Item\Iface $item Updated item including the generated ID
372
	 */
373
	public function saveItem( \Aimeos\MShop\Customer\Item\Iface $item, bool $fetch = true ) : \Aimeos\MShop\Customer\Item\Iface
374
	{
375
		if( !$item->isModified() )
376
		{
377
			$item = $this->savePropertyItems( $item, 'customer' );
378
			$item = $this->saveAddressItems( $item, 'customer' );
379
			return $this->saveListItems( $item, 'customer' );
380
		}
381
382
		$context = $this->getContext();
383
384
		$class = '\Aimeos\MShop\Context\Item\Ezpublish';
385
		if( !is_a( $context, $class ) ) {
386
			throw new \Aimeos\MShop\Customer\Exception( sprintf( 'Object is not of required type "%1$s"', $class ) );
387
		}
388
389
		$service = $context->getEzUserService();
390
		$email = $item->getPaymentAddress()->getEmail();
391
392
		if( $item->getId() !== null )
393
		{
394
			$struct = $service->newUserUpdateStruct();
395
			$struct->password = $item->getPassword();
396
			$struct->enabled = $item->getStatus();
397
			$struct->email = $email;
398
399
			$user = $service->loadUser( $item->getId() );
400
			$service->updateUser( $user, $struct );
401
		}
402
		else
403
		{
404
			$struct = $service->newUserCreateStruct( $item->getCode(), $email, $item->getPassword(), 'eng-GB' );
405
			$struct->enabled = $item->getStatus();
406
407
			$user = $service->createUser( $struct, [] );
408
			$item->setId( $user->getUserId() );
409
		}
410
411
		$dbm = $context->getDatabaseManager();
412
		$dbname = $this->getResourceName();
413
		$conn = $dbm->acquire( $dbname );
414
415
		try
416
		{
417
			$date = date( 'Y-m-d H:i:s' );
418
			$columns = $this->getObject()->getSaveAttributes();
419
			$ctime = ( $item->getTimeCreated() ? $item->getTimeCreated() : $date );
420
			$billingAddress = $item->getPaymentAddress();
421
422
			$path = 'mshop/customer/manager/ezpublish/update';
423
			$sql = $this->addSqlColumns( array_keys( $columns ), $this->getSqlConfig( $path ), false );
0 ignored issues
show
Bug introduced by
It seems like $this->getSqlConfig($path) can also be of type array; however, parameter $sql of Aimeos\MShop\Common\Manager\Base::addSqlColumns() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

423
			$sql = $this->addSqlColumns( array_keys( $columns ), /** @scrutinizer ignore-type */ $this->getSqlConfig( $path ), false );
Loading history...
424
			$stmt = $this->getCachedStatement( $conn, $path, $sql );
0 ignored issues
show
Unused Code introduced by
The assignment to $stmt is dead and can be removed.
Loading history...
425
426
			$idx = 1;
427
			$stmt = $this->getCachedStatement( $conn, $path, $sql );
428
429
			foreach( $columns as $name => $entry ) {
430
				$stmt->bind( $idx++, $item->get( $name ), $entry->getInternalType() );
431
			}
432
433
			$stmt->bind( $idx++, $billingAddress->getCompany() );
434
			$stmt->bind( $idx++, $billingAddress->getVatID() );
435
			$stmt->bind( $idx++, $billingAddress->getSalutation() );
436
			$stmt->bind( $idx++, $billingAddress->getTitle() );
437
			$stmt->bind( $idx++, $billingAddress->getFirstname() );
438
			$stmt->bind( $idx++, $billingAddress->getLastname() );
439
			$stmt->bind( $idx++, $billingAddress->getAddress1() );
440
			$stmt->bind( $idx++, $billingAddress->getAddress2() );
441
			$stmt->bind( $idx++, $billingAddress->getAddress3() );
442
			$stmt->bind( $idx++, $billingAddress->getPostal() );
443
			$stmt->bind( $idx++, $billingAddress->getCity() );
444
			$stmt->bind( $idx++, $billingAddress->getState() );
445
			$stmt->bind( $idx++, $billingAddress->getCountryId() );
446
			$stmt->bind( $idx++, $billingAddress->getLanguageId() );
447
			$stmt->bind( $idx++, $billingAddress->getTelephone() );
448
			$stmt->bind( $idx++, $billingAddress->getTelefax() );
449
			$stmt->bind( $idx++, $billingAddress->getWebsite() );
450
			$stmt->bind( $idx++, $item->getBirthday() );
451
			$stmt->bind( $idx++, $item->getDateVerified() );
452
			$stmt->bind( $idx++, $date ); // Modification time
453
			$stmt->bind( $idx++, $context->getEditor() );
454
			$stmt->bind( $idx++, $ctime ); // Creation time
455
			$stmt->bind( $idx++, $item->getId(), \Aimeos\MW\DB\Statement\Base::PARAM_INT );
456
457
			$stmt->execute()->finish();
458
459
			$dbm->release( $conn, $dbname );
460
		}
461
		catch( \Exception $e )
462
		{
463
			$dbm->release( $conn, $dbname );
464
			throw $e;
465
		}
466
467
		$item = $this->savePropertyItems( $item, 'customer' );
468
		$item = $this->saveAddressItems( $item, 'customer' );
469
		return $this->saveListItems( $item, 'customer' );
470
	}
471
472
473
	/**
474
	 * Returns the item objects matched by the given search criteria.
475
	 *
476
	 * @param \Aimeos\MW\Criteria\Iface $search Search criteria object
477
	 * @param integer &$total Number of items that are available in total
478
	 * @return \Aimeos\Map List of items implementing \Aimeos\MShop\Customer\Item\Iface
479
	 * @throws \Aimeos\MShop\Customer\Exception If creating items failed
480
	 */
481
	public function searchItems( \Aimeos\MW\Criteria\Iface $search, array $ref = [], int &$total = null ) : \Aimeos\Map
482
	{
483
		$dbm = $this->getContext()->getDatabaseManager();
484
		$dbname = $this->getResourceName();
485
		$conn = $dbm->acquire( $dbname );
486
		$map = [];
487
488
		try
489
		{
490
			$level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL;
491
			$cfgPathSearch = 'mshop/customer/manager/ezpublish/search';
492
			$cfgPathCount = 'mshop/customer/manager/ezpublish/count';
493
			$required = array( 'customer' );
494
495
			$results = $this->searchItemsBase( $conn, $search, $cfgPathSearch, $cfgPathCount, $required, $total, $level );
496
497
			while( ( $row = $results->fetch() ) !== null )
498
			{
499
				$map[$row['customer.id']] = $row;
500
				$map[$row['customer.id']]['customer.groups'] = [];
501
			}
502
503
504
			$path = 'mshop/customer/manager/ezpublish/groups';
505
			$stmt = $conn->create( $this->getGroupSql( array_keys( $map ), $path ) );
506
			$results = $stmt->execute();
507
508
			while( ( $row = $results->fetch() ) !== null ) {
509
				$map[(string) $row['contentobject_id']]['customer.groups'][] = $row['role_id'];
510
			}
511
512
			$dbm->release( $conn, $dbname );
513
		}
514
		catch( \Exception $e )
515
		{
516
			$dbm->release( $conn, $dbname );
517
			throw $e;
518
		}
519
520
		$addrItems = [];
521
		if( in_array( 'customer/address', $ref, true ) ) {
522
			$addrItems = $this->getAddressItems( array_keys( $map ), 'customer' );
523
		}
524
525
		$propItems = []; $name = 'customer/property';
526
		if( isset( $ref[$name] ) || in_array( $name, $ref, true ) )
527
		{
528
			$propTypes = isset( $ref[$name] ) && is_array( $ref[$name] ) ? $ref[$name] : null;
529
			$propItems = $this->getPropertyItems( array_keys( $map ), 'customer', $propTypes );
530
		}
531
532
		return $this->buildItems( $map, $ref, 'customer', $addrItems, $propItems );
533
	}
534
535
536
	/**
537
	 * Creates a new customer item.
538
	 *
539
	 * @param array $values List of attributes for customer item
540
	 * @param \Aimeos\MShop\Common\Lists\Item\Iface[] $listItems List of list items
541
	 * @param \Aimeos\MShop\Common\Item\Iface[] $refItems List of referenced items
542
	 * @param \Aimeos\MShop\Common\Item\Address\Iface[] $addrItems List of referenced address items
543
	 * @param \Aimeos\MShop\Common\Item\Property\Iface[] $propItems List of property items
544
	 * @return \Aimeos\MShop\Customer\Item\Iface New customer item
545
	 */
546
	protected function createItemBase( array $values = [], array $listItems = [], array $refItems = [],
547
		array $addrItems = [], array $propItems = [] ) : \Aimeos\MShop\Common\Item\Iface
548
	{
549
		$address = new \Aimeos\MShop\Common\Item\Address\Simple( 'customer.', $values );
550
551
		return new \Aimeos\MShop\Customer\Item\Ezpublish(
552
			$address, $values, $listItems, $refItems, $addrItems, $propItems
553
		);
554
	}
555
556
557
	/**
558
	 * Returns the SQL statement for retrieving the customer group IDs
559
	 *
560
	 * @param array $ids List of customer IDs
561
	 * @param string $cfgpath Configuration path to the SQL statement
562
	 * @return string SQL statement ready for execution
563
	 */
564
	protected function getGroupSql( array $ids, string $cfgpath ) : string
565
	{
566
		if( empty( $ids ) ) { return '1=1'; }
567
568
		$search = $this->getObject()->createSearch();
569
		$search->setConditions( $search->compare( '==', 'id', $ids ) );
570
571
		$types = array( 'id' => \Aimeos\MW\DB\Statement\Base::PARAM_INT );
572
		$translations = array( 'id' => '"contentobject_id"' );
573
574
		$cond = $search->getConditionSource( $types, $translations );
575
576
		return str_replace( ':cond', $cond, $this->getSqlConfig( $cfgpath ) );
577
	}
578
}
579