Passed
Push — master ( ef7004...60f145 )
by Aimeos
09:20
created

Standard::search()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 134
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 134
rs 9.7998
c 0
b 0
f 0
cc 3
nc 3
nop 3

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
4
 * @copyright Aimeos (aimeos.org), 2022
5
 * @package MShop
6
 * @subpackage Order
7
 */
8
9
namespace Aimeos\MShop\Order\Manager\Basket;
10
11
12
/**
13
 * Default implementation for order basket manager.
14
 *
15
 * @package MShop
16
 * @subpackage Order
17
 */
18
class Standard
19
	extends \Aimeos\MShop\Common\Manager\Base
20
	implements \Aimeos\MShop\Order\Manager\Basket\Iface, \Aimeos\MShop\Common\Manager\Factory\Iface
21
{
22
	private $searchConfig = array(
23
		'order.basket.id' => array(
24
			'code' => 'order.basket.id',
25
			'internalcode' => 'mordba."id"',
26
			'label' => 'Basket ID',
27
			'type' => 'string',
28
			'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_STR,
29
			'public' => false,
30
		),
31
		'order.basket.siteid' => array(
32
			'code' => 'order.basket.siteid',
33
			'internalcode' => 'mordba."siteid"',
34
			'label' => 'Basket site ID',
35
			'type' => 'string',
36
			'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_STR,
37
			'public' => false,
38
		),
39
		'order.basket.customerid' => array(
40
			'code' => 'order.basket.customerid',
41
			'internalcode' => 'mordba."customerid"',
42
			'label' => 'Basket customer ID',
43
			'type' => 'string',
44
			'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_STR,
45
			'public' => false,
46
		),
47
		'order.basket.name' => array(
48
			'code' => 'order.basket.name',
49
			'internalcode' => 'mordba."name"',
50
			'label' => 'Basket name',
51
			'type' => 'string',
52
			'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_STR,
53
		),
54
		'order.basket.content' => array(
55
			'code' => 'order.basket.content',
56
			'internalcode' => 'mordba."content"',
57
			'label' => 'Basket content',
58
			'type' => 'string',
59
			'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_STR,
60
		),
61
		'order.basket.ctime' => array(
62
			'code' => 'order.basket.ctime',
63
			'internalcode' => 'mordba."ctime"',
64
			'label' => 'Basket create date/time',
65
			'type' => 'datetime',
66
			'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_STR,
67
			'public' => false,
68
		),
69
		'order.basket.mtime' => array(
70
			'code' => 'order.basket.mtime',
71
			'internalcode' => 'mordba."mtime"',
72
			'label' => 'Basket modify date/time',
73
			'type' => 'datetime',
74
			'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_STR,
75
			'public' => false,
76
		),
77
		'order.basket.editor' => array(
78
			'code' => 'order.basket.editor',
79
			'internalcode' => 'mordba."editor"',
80
			'label' => 'Basket editor',
81
			'type' => 'string',
82
			'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_STR,
83
			'public' => false,
84
		),
85
	);
86
87
88
	/**
89
	 * Initializes the object.
90
	 *
91
	 * @param \Aimeos\MShop\ContextIface $context Context object
92
	 */
93
	public function __construct( \Aimeos\MShop\ContextIface $context )
94
	{
95
		parent::__construct( $context );
96
		$this->setResourceName( 'db-order' );
97
	}
98
99
100
	/**
101
	 * Removes old entries from the storage.
102
	 *
103
	 * @param iterable $siteids List of IDs for sites whose entries should be deleted
104
	 * @return \Aimeos\MShop\Order\Manager\Basket\Iface Manager object for chaining method calls
105
	 */
106
	public function clear( iterable $siteids ) : \Aimeos\MShop\Common\Manager\Iface
107
	{
108
		$path = 'mshop/order/manager/basket/submanagers';
109
		foreach( $this->context()->config()->get( $path, [] ) as $domain ) {
110
			$this->object()->getSubManager( $domain )->clear( $siteids );
111
		}
112
113
		return $this->clearBase( $siteids, 'mshop/order/manager/basket/delete' );
114
	}
115
116
117
	/**
118
	 * Creates a new empty item instance
119
	 *
120
	 * @param array $values Values the item should be initialized with
121
	 * @return \Aimeos\MShop\Order\Item\Basket\Iface New order basket item object
122
	 */
123
	public function create( array $values = [] ) : \Aimeos\MShop\Common\Item\Iface
124
	{
125
		$values['order.basket.siteid'] = $values['order.basket.siteid'] ?? $this->context()->locale()->getSiteId();
126
		return $this->createItemBase( $values );
127
	}
128
129
130
	/**
131
	 * Adds or updates an order basket object.
132
	 *
133
	 * @param \Aimeos\MShop\Order\Item\Basket\Iface $item Order basket object whose data should be saved
134
	 * @param bool $fetch True if the new ID should be returned in the item
135
	 * @return \Aimeos\MShop\Order\Item\Basket\Iface $item Updated item including the generated ID
136
	 */
137
	public function saveItem( \Aimeos\MShop\Order\Item\Basket\Iface $item, bool $fetch = true ) : \Aimeos\MShop\Order\Item\Basket\Iface
138
	{
139
		if( !$item->isModified() ) {
140
			return $item;
141
		}
142
143
		$context = $this->context();
144
		$conn = $context->db( $this->getResourceName() );
145
		$date = date( 'Y-m-d H:i:s' );
146
147
		/** mshop/order/manager/basket/insert/mysql
148
		 * Inserts a new basket record into the database table or updates an existing one
149
		 *
150
		 * The SQL statement must be a string suitable for being used as
151
		 * prepared statement. It must include question marks for binding
152
		 * the values from the order item to the statement before they are
153
		 * sent to the database server. The number of question marks must
154
		 * be the same as the number of columns listed in the INSERT
155
		 * statement. The order of the columns must correspond to the
156
		 * order in the save() method, so the correct values are
157
		 * bound to the columns.
158
		 *
159
		 * The SQL statement should conform to the ANSI standard to be
160
		 * compatible with most relational database systems. This also
161
		 * includes using double quotes for table and column names.
162
		 *
163
		 * @param string SQL statement for inserting or updating records
164
		 * @since 2022.10
165
		 * @category Developer
166
		 * @see mshop/order/manager/basket/newid/ansi
167
		 * @see mshop/order/manager/basket/delete/ansi
168
		 * @see mshop/order/manager/basket/search/ansi
169
		 * @see mshop/order/manager/basket/count/ansi
170
		 */
171
		$path = 'mshop/order/manager/basket/insert';
172
173
		$sql = $this->getSqlConfig( 'mshop/order/manager/basket/insert' );
174
		$stmt = $this->getCachedStatement( $conn, $path, $sql );
0 ignored issues
show
Bug introduced by
It seems like $sql can also be of type array; however, parameter $sql of Aimeos\MShop\Common\Mana...e::getCachedStatement() does only seem to accept null|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

174
		$stmt = $this->getCachedStatement( $conn, $path, /** @scrutinizer ignore-type */ $sql );
Loading history...
175
		$idx = 1;
176
177
		// insert
178
		$stmt->bind( $idx++, $item->getCustomerId() );
179
		$stmt->bind( $idx++, $item->getContent() );
180
		$stmt->bind( $idx++, $item->getName() );
181
		$stmt->bind( $idx++, $date ); //mtime
182
		$stmt->bind( $idx++, $context->editor() );
183
		$stmt->bind( $idx++, $context->locale()->getSiteId() );
184
		$stmt->bind( $idx++, $date ); //ctime
185
		$stmt->bind( $idx++, $item->getId() );
186
		// update
187
		$stmt->bind( $idx++, $item->getCustomerId() );
188
		$stmt->bind( $idx++, $item->getContent() );
189
		$stmt->bind( $idx++, $item->getName() );
190
		$stmt->bind( $idx++, $date ); //mtime
191
		$stmt->bind( $idx++, $context->editor() );
192
193
		$stmt->execute()->finish();
194
195
		return $item;
196
	}
197
198
199
	/**
200
	 * Returns the order basket item specified by its ID.
201
	 *
202
	 * @param string $id Unique ID of the order basket item
203
	 * @param string[] $ref List of domains to fetch list items and referenced items for
204
	 * @param bool|null $default Add default criteria or NULL for relaxed default criteria
205
	 * @return \Aimeos\MShop\Order\Item\Basket\Iface Returns order basket item of the given id
206
	 * @throws \Aimeos\MShop\Order\Exception If item couldn't be found
207
	 */
208
	public function get( string $id, array $ref = [], ?bool $default = false ) : \Aimeos\MShop\Common\Item\Iface
209
	{
210
		return $this->getItemBase( 'order.basket.id', $id, $ref, $default );
211
	}
212
213
214
	/**
215
	 * Removes multiple items.
216
	 *
217
	 * @param \Aimeos\MShop\Common\Item\Iface[]|string[] $itemIds List of item objects or IDs of the items
218
	 * @return \Aimeos\MShop\Order\Manager\Basket\Iface Manager object for chaining method calls
219
	 */
220
	public function delete( $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
221
	{
222
		/** mshop/order/manager/basket/delete/mysql
223
		 * Deletes the items matched by the given IDs from the database
224
		 *
225
		 * @see mshop/order/manager/basket/delete/ansi
226
		 */
227
228
		/** mshop/order/manager/basket/delete/ansi
229
		 * Deletes the items matched by the given IDs from the database
230
		 *
231
		 * Removes the records specified by the given IDs from the order database.
232
		 * The records must be from the site that is configured via the
233
		 * context item.
234
		 *
235
		 * The ":cond" placeholder is replaced by the name of the ID column and
236
		 * the given ID or list of IDs while the site ID is bound to the question
237
		 * mark.
238
		 *
239
		 * The SQL statement should conform to the ANSI standard to be
240
		 * compatible with most relational database systems. This also
241
		 * includes using double quotes for table and column names.
242
		 *
243
		 * @param string SQL statement for deleting items
244
		 * @since 2022.10
245
		 * @category Developer
246
		 * @see mshop/order/manager/basket/insert/ansi
247
		 * @see mshop/order/manager/basket/update/ansi
248
		 * @see mshop/order/manager/basket/newid/ansi
249
		 * @see mshop/order/manager/basket/search/ansi
250
		 * @see mshop/order/manager/basket/count/ansi
251
		 */
252
		$path = 'mshop/order/manager/basket/delete';
253
254
		return $this->deleteItemsBase( $itemIds, $path );
255
	}
256
257
258
	/**
259
	 * Returns the available manager types
260
	 *
261
	 * @param bool $withsub Return also the resource type of sub-managers if true
262
	 * @return string[] Type of the manager and submanagers, subtypes are separated by slashes
263
	 */
264
	public function getResourceType( bool $withsub = true ) : array
265
	{
266
		$path = 'mshop/order/manager/basket/submanagers';
267
268
		return $this->getResourceTypeBase( 'order/basket', $path, [], $withsub );
269
	}
270
271
272
	/**
273
	 * Returns the attributes that can be used for searching.
274
	 *
275
	 * @param bool $withsub Return also attributes of sub-managers if true
276
	 * @return \Aimeos\Base\Criteria\Attribute\Iface[] List of search attribute items
277
	 */
278
	public function getSearchAttributes( bool $withsub = true ) : array
279
	{
280
		/** mshop/order/manager/basket/submanagers
281
		 * List of manager names that can be instantiated by the order basket manager
282
		 *
283
		 * Managers provide a generic interface to the underlying storage.
284
		 * Each manager has or can have sub-managers caring about particular
285
		 * aspects. Each of these sub-managers can be instantiated by its
286
		 * parent manager using the getSubManager() method.
287
		 *
288
		 * The search keys from sub-managers can be normally used in the
289
		 * manager as well. It allows you to search for items of the manager
290
		 * using the search keys of the sub-managers to further limit the
291
		 * retrieved list of items.
292
		 *
293
		 * @param array List of sub-manager names
294
		 * @since 2022.10
295
		 * @category Developer
296
		 */
297
		$path = 'mshop/order/manager/basket/submanagers';
298
299
		return $this->getSearchAttributesBase( $this->searchConfig, $path, [], $withsub );
300
	}
301
302
303
	/**
304
	 * Returns a new manager for order basket extensions.
305
	 *
306
	 * @param string $manager Name of the sub manager type in lower case
307
	 * @param string|null $name Name of the implementation, will be from configuration (or Default) if null
308
	 * @return \Aimeos\MShop\Common\Manager\Iface Manager extending the domain functionality
309
	 */
310
	public function getSubManager( string $manager, string $name = null ) : \Aimeos\MShop\Common\Manager\Iface
311
	{
312
		/** mshop/order/manager/basket/name
313
		 * Class name of the used order basket manager implementation
314
		 *
315
		 * Each default order basket manager can be replaced by an alternative imlementation.
316
		 * To use this implementation, you have to set the last part of the class
317
		 * name as configuration value so the manager factory knows which class it
318
		 * has to instantiate.
319
		 *
320
		 * For example, if the name of the default class is
321
		 *
322
		 *  \Aimeos\MShop\Order\Manager\Basket\Standard
323
		 *
324
		 * and you want to replace it with your own version named
325
		 *
326
		 *  \Aimeos\MShop\Order\Manager\Basket\Mybasket
327
		 *
328
		 * then you have to set the this configuration option:
329
		 *
330
		 *  mshop/order/manager/basket/name = Mybasket
331
		 *
332
		 * The value is the last part of your own class name and it's case sensitive,
333
		 * so take care that the configuration value is exactly named like the last
334
		 * part of the class name.
335
		 *
336
		 * The allowed characters of the class name are A-Z, a-z and 0-9. No other
337
		 * characters are possible! You should always start the last part of the class
338
		 * name with an upper case character and continue only with lower case characters
339
		 * or numbers. Avoid chamel case names like "MyBasket"!
340
		 *
341
		 * @param string Last part of the class name
342
		 * @since 2022.10
343
		 * @category Developer
344
		 */
345
346
		/** mshop/order/manager/basket/decorators/excludes
347
		 * Excludes decorators added by the "common" option from the order basket manager
348
		 *
349
		 * Decorators extend the functionality of a class by adding new aspects
350
		 * (e.g. log what is currently done), executing the methods of the underlying
351
		 * class only in certain conditions (e.g. only for logged in users) or
352
		 * modify what is returned to the caller.
353
		 *
354
		 * This option allows you to remove a decorator added via
355
		 * "mshop/common/manager/decorators/default" before they are wrapped
356
		 * around the order basket manager.
357
		 *
358
		 *  mshop/order/manager/basket/decorators/excludes = array( 'decorator1' )
359
		 *
360
		 * This would remove the decorator named "decorator1" from the list of
361
		 * common decorators ("\Aimeos\MShop\Common\Manager\Decorator\*") added via
362
		 * "mshop/common/manager/decorators/default" for the order basket manager.
363
		 *
364
		 * @param array List of decorator names
365
		 * @since 2022.10
366
		 * @category Developer
367
		 * @see mshop/common/manager/decorators/default
368
		 * @see mshop/order/manager/basket/decorators/global
369
		 * @see mshop/order/manager/basket/decorators/local
370
		 */
371
372
		/** mshop/order/manager/basket/decorators/global
373
		 * Adds a list of globally available decorators only to the order basket manager
374
		 *
375
		 * Decorators extend the functionality of a class by adding new aspects
376
		 * (e.g. log what is currently done), executing the methods of the underlying
377
		 * class only in certain conditions (e.g. only for logged in users) or
378
		 * modify what is returned to the caller.
379
		 *
380
		 * This option allows you to wrap global decorators
381
		 * ("\Aimeos\MShop\Common\Manager\Decorator\*") around the order basket
382
		 * manager.
383
		 *
384
		 *  mshop/order/manager/basket/decorators/global = array( 'decorator1' )
385
		 *
386
		 * This would add the decorator named "decorator1" defined by
387
		 * "\Aimeos\MShop\Common\Manager\Decorator\Decorator1" only to the order
388
		 * basket manager.
389
		 *
390
		 * @param array List of decorator names
391
		 * @since 2022.10
392
		 * @category Developer
393
		 * @see mshop/common/manager/decorators/default
394
		 * @see mshop/order/manager/basket/decorators/excludes
395
		 * @see mshop/order/manager/basket/decorators/local
396
		 */
397
398
		/** mshop/order/manager/basket/decorators/local
399
		 * Adds a list of local decorators only to the order basket manager
400
		 *
401
		 * Decorators extend the functionality of a class by adding new aspects
402
		 * (e.g. log what is currently done), executing the methods of the underlying
403
		 * class only in certain conditions (e.g. only for logged in users) or
404
		 * modify what is returned to the caller.
405
		 *
406
		 * This option allows you to wrap local decorators
407
		 * ("\Aimeos\MShop\Order\Manager\Basket\Decorator\*") around the order
408
		 * basket manager.
409
		 *
410
		 *  mshop/order/manager/basket/decorators/local = array( 'decorator2' )
411
		 *
412
		 * This would add the decorator named "decorator2" defined by
413
		 * "\Aimeos\MShop\Order\Manager\Basket\Decorator\Decorator2" only to the
414
		 * order basket manager.
415
		 *
416
		 * @param array List of decorator names
417
		 * @since 2022.10
418
		 * @category Developer
419
		 * @see mshop/common/manager/decorators/default
420
		 * @see mshop/order/manager/basket/decorators/excludes
421
		 * @see mshop/order/manager/basket/decorators/global
422
		 */
423
424
		return $this->getSubManagerBase( 'order', 'basket/' . $manager, $name );
425
	}
426
427
428
	/**
429
	 * Searches for all items matching the given critera.
430
	 *
431
	 * @param \Aimeos\Base\Criteria\Iface $search Search criteria object
432
	 * @param string[] $ref List of domains to fetch list items and referenced items for
433
	 * @param int|null &$total Number of items that are available in total
434
	 * @return \Aimeos\Map List of items implementing \Aimeos\MShop\Order\Item\Basket\Iface with ids as keys
435
	 */
436
	public function search( \Aimeos\Base\Criteria\Iface $search, array $ref = [], int &$total = null ) : \Aimeos\Map
437
	{
438
		$items = [];
439
		$context = $this->context();
440
		$conn = $context->db( $this->getResourceName() );
441
442
			$required = array( 'order.basket' );
443
444
			$level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL;
445
			$level = $context->config()->get( 'mshop/order/manager/sitemode', $level );
446
447
			/** mshop/order/manager/basket/search/mysql
448
			 * Retrieves the records matched by the given criteria in the database
449
			 *
450
			 * @see mshop/order/manager/basket/search/ansi
451
			 */
452
453
			/** mshop/order/manager/basket/search/ansi
454
			 * Retrieves the records matched by the given criteria in the database
455
			 *
456
			 * Fetches the records matched by the given criteria from the order
457
			 * database. The records must be from one of the sites that are
458
			 * configured via the context item. If the current site is part of
459
			 * a tree of sites, the SELECT statement can retrieve all records
460
			 * from the current site and the complete sub-tree of sites.
461
			 *
462
			 * As the records can normally be limited by criteria from sub-managers,
463
			 * their tables must be joined in the SQL context. This is done by
464
			 * using the "internaldeps" property from the definition of the ID
465
			 * column of the sub-managers. These internal dependencies specify
466
			 * the JOIN between the tables and the used columns for joining. The
467
			 * ":joins" placeholder is then replaced by the JOIN strings from
468
			 * the sub-managers.
469
			 *
470
			 * To limit the records matched, conditions can be added to the given
471
			 * criteria object. It can contain comparisons like column names that
472
			 * must match specific values which can be combined by AND, OR or NOT
473
			 * operators. The resulting string of SQL conditions replaces the
474
			 * ":cond" placeholder before the statement is sent to the database
475
			 * server.
476
			 *
477
			 * If the records that are retrieved should be ordered by one or more
478
			 * columns, the generated string of column / sort direction pairs
479
			 * replaces the ":order" placeholder. In case no ordering is required,
480
			 * the complete ORDER BY part including the "\/*-orderby*\/...\/*orderby-*\/"
481
			 * markers is removed to speed up retrieving the records. Columns of
482
			 * sub-managers can also be used for ordering the result set but then
483
			 * no index can be used.
484
			 *
485
			 * The number of returned records can be limited and can start at any
486
			 * number between the begining and the end of the result set. For that
487
			 * the ":size" and ":start" placeholders are replaced by the
488
			 * corresponding values from the criteria object. The default values
489
			 * are 0 for the start and 100 for the size value.
490
			 *
491
			 * The SQL statement should conform to the ANSI standard to be
492
			 * compatible with most relational database systems. This also
493
			 * includes using double quotes for table and column names.
494
			 *
495
			 * @param string SQL statement for searching items
496
			 * @since 2022.10
497
			 * @category Developer
498
			 * @see mshop/order/manager/basket/insert/ansi
499
			 * @see mshop/order/manager/basket/update/ansi
500
			 * @see mshop/order/manager/basket/newid/ansi
501
			 * @see mshop/order/manager/basket/delete/ansi
502
			 * @see mshop/order/manager/basket/count/ansi
503
			 */
504
			$cfgPathSearch = 'mshop/order/manager/basket/search';
505
506
			/** mshop/order/manager/basket/count/mysql
507
			 * Counts the number of records matched by the given criteria in the database
508
			 *
509
			 * @see mshop/order/manager/basket/count/ansi
510
			 */
511
512
			/** mshop/order/manager/basket/count/ansi
513
			 * Counts the number of records matched by the given criteria in the database
514
			 *
515
			 * Counts all records matched by the given criteria from the order
516
			 * database. The records must be from one of the sites that are
517
			 * configured via the context item. If the current site is part of
518
			 * a tree of sites, the statement can count all records from the
519
			 * current site and the complete sub-tree of sites.
520
			 *
521
			 * As the records can normally be limited by criteria from sub-managers,
522
			 * their tables must be joined in the SQL context. This is done by
523
			 * using the "internaldeps" property from the definition of the ID
524
			 * column of the sub-managers. These internal dependencies specify
525
			 * the JOIN between the tables and the used columns for joining. The
526
			 * ":joins" placeholder is then replaced by the JOIN strings from
527
			 * the sub-managers.
528
			 *
529
			 * To limit the records matched, conditions can be added to the given
530
			 * criteria object. It can contain comparisons like column names that
531
			 * must match specific values which can be combined by AND, OR or NOT
532
			 * operators. The resulting string of SQL conditions replaces the
533
			 * ":cond" placeholder before the statement is sent to the database
534
			 * server.
535
			 *
536
			 * Both, the strings for ":joins" and for ":cond" are the same as for
537
			 * the "search" SQL statement.
538
			 *
539
			 * Contrary to the "search" statement, it doesn't return any records
540
			 * but instead the number of records that have been found. As counting
541
			 * thousands of records can be a long running task, the maximum number
542
			 * of counted records is limited for performance reasons.
543
			 *
544
			 * The SQL statement should conform to the ANSI standard to be
545
			 * compatible with most relational database systems. This also
546
			 * includes using double quotes for table and column names.
547
			 *
548
			 * @param string SQL statement for counting items
549
			 * @since 2022.10
550
			 * @category Developer
551
			 * @see mshop/order/manager/basket/insert/ansi
552
			 * @see mshop/order/manager/basket/update/ansi
553
			 * @see mshop/order/manager/basket/newid/ansi
554
			 * @see mshop/order/manager/basket/delete/ansi
555
			 * @see mshop/order/manager/basket/search/ansi
556
			 */
557
			$cfgPathCount = 'mshop/order/manager/basket/count';
558
559
			$results = $this->searchItemsBase( $conn, $search, $cfgPathSearch, $cfgPathCount,
560
				$required, $total, $level );
561
562
			while( ( $row = $results->fetch() ) !== null )
563
			{
564
				if( $item = $this->createItemBase( $row ) ) {
565
					$items[$row['order.basket.id']] = $item;
566
				}
567
			}
568
569
		return map( $items );
570
	}
571
572
573
	/**
574
	 * Creates a new order basket object.
575
	 *
576
	 * @param array $values List of attributes for the order basket object
577
	 * @return \Aimeos\MShop\Order\Item\Basket\Iface New order basket object
578
	 */
579
	protected function createItemBase( array $values = [] ) : \Aimeos\MShop\Order\Item\Basket\Iface
580
	{
581
		return new \Aimeos\MShop\Order\Item\Basket\Standard( $values );
582
	}
583
}
584