1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2018 |
6
|
|
|
* @package MShop |
7
|
|
|
* @subpackage Customer |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\MShop\Customer\Manager; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Customer class implementation for Friends of Symfony user bundle. |
16
|
|
|
* |
17
|
|
|
* @package MShop |
18
|
|
|
* @subpackage Customer |
19
|
|
|
*/ |
20
|
|
|
class Laravel |
21
|
|
|
extends \Aimeos\MShop\Customer\Manager\Standard |
22
|
|
|
{ |
23
|
|
|
private $searchConfig = array( |
24
|
|
|
// customer.siteid is only for informational purpuse, not for filtering |
25
|
|
|
'customer.id' => array( |
26
|
|
|
'label' => 'Customer ID', |
27
|
|
|
'code' => 'customer.id', |
28
|
|
|
'internalcode' => 'lvu."id"', |
29
|
|
|
'type' => 'integer', |
30
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT, |
31
|
|
|
'public' => false, |
32
|
|
|
), |
33
|
|
|
'customer.code' => array( |
34
|
|
|
'label' => 'Customer username', |
35
|
|
|
'code' => 'customer.code', |
36
|
|
|
'internalcode' => 'lvu."name"', |
37
|
|
|
'type' => 'string', |
38
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR |
39
|
|
|
), |
40
|
|
|
'customer.label' => array( |
41
|
|
|
'label' => 'Customer label', |
42
|
|
|
'code' => 'customer.label', |
43
|
|
|
'internalcode' => 'lvu."label"', |
44
|
|
|
'type' => 'string', |
45
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR |
46
|
|
|
), |
47
|
|
|
'customer.salutation' => array( |
48
|
|
|
'label' => 'Customer salutation', |
49
|
|
|
'code' => 'customer.salutation', |
50
|
|
|
'internalcode' => 'lvu."salutation"', |
51
|
|
|
'type' => 'string', |
52
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
53
|
|
|
), |
54
|
|
|
'customer.company'=> array( |
55
|
|
|
'label' => 'Customer company', |
56
|
|
|
'code' => 'customer.company', |
57
|
|
|
'internalcode' => 'lvu."company"', |
58
|
|
|
'type' => 'string', |
59
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
60
|
|
|
), |
61
|
|
|
'customer.vatid'=> array( |
62
|
|
|
'label' => 'Customer VAT ID', |
63
|
|
|
'code' => 'customer.vatid', |
64
|
|
|
'internalcode' => 'lvu."vatid"', |
65
|
|
|
'type' => 'string', |
66
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
67
|
|
|
), |
68
|
|
|
'customer.title' => array( |
69
|
|
|
'label' => 'Customer title', |
70
|
|
|
'code' => 'customer.title', |
71
|
|
|
'internalcode' => 'lvu."title"', |
72
|
|
|
'type' => 'string', |
73
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
74
|
|
|
), |
75
|
|
|
'customer.firstname' => array( |
76
|
|
|
'label' => 'Customer firstname', |
77
|
|
|
'code' => 'customer.firstname', |
78
|
|
|
'internalcode' => 'lvu."firstname"', |
79
|
|
|
'type' => 'string', |
80
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
81
|
|
|
), |
82
|
|
|
'customer.lastname' => array( |
83
|
|
|
'label' => 'Customer lastname', |
84
|
|
|
'code' => 'customer.lastname', |
85
|
|
|
'internalcode' => 'lvu."lastname"', |
86
|
|
|
'type' => 'string', |
87
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
88
|
|
|
), |
89
|
|
|
'customer.address1' => array( |
90
|
|
|
'label' => 'Customer address part one', |
91
|
|
|
'code' => 'customer.address1', |
92
|
|
|
'internalcode' => 'lvu."address1"', |
93
|
|
|
'type' => 'string', |
94
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
95
|
|
|
), |
96
|
|
|
'customer.address2' => array( |
97
|
|
|
'label' => 'Customer address part two', |
98
|
|
|
'code' => 'customer.address2', |
99
|
|
|
'internalcode' => 'lvu."address2"', |
100
|
|
|
'type' => 'string', |
101
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
102
|
|
|
), |
103
|
|
|
'customer.address3' => array( |
104
|
|
|
'label' => 'Customer address part three', |
105
|
|
|
'code' => 'customer.address3', |
106
|
|
|
'internalcode' => 'lvu."address3"', |
107
|
|
|
'type' => 'string', |
108
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
109
|
|
|
), |
110
|
|
|
'customer.postal' => array( |
111
|
|
|
'label' => 'Customer postal', |
112
|
|
|
'code' => 'customer.postal', |
113
|
|
|
'internalcode' => 'lvu."postal"', |
114
|
|
|
'type' => 'string', |
115
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
116
|
|
|
), |
117
|
|
|
'customer.city' => array( |
118
|
|
|
'label' => 'Customer city', |
119
|
|
|
'code' => 'customer.city', |
120
|
|
|
'internalcode' => 'lvu."city"', |
121
|
|
|
'type' => 'string', |
122
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
123
|
|
|
), |
124
|
|
|
'customer.state' => array( |
125
|
|
|
'label' => 'Customer state', |
126
|
|
|
'code' => 'customer.state', |
127
|
|
|
'internalcode' => 'lvu."state"', |
128
|
|
|
'type' => 'string', |
129
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
130
|
|
|
), |
131
|
|
|
'customer.languageid' => array( |
132
|
|
|
'label' => 'Customer language', |
133
|
|
|
'code' => 'customer.languageid', |
134
|
|
|
'internalcode' => 'lvu."langid"', |
135
|
|
|
'type' => 'string', |
136
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
137
|
|
|
), |
138
|
|
|
'customer.countryid' => array( |
139
|
|
|
'label' => 'Customer country', |
140
|
|
|
'code' => 'customer.countryid', |
141
|
|
|
'internalcode' => 'lvu."countryid"', |
142
|
|
|
'type' => 'string', |
143
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
144
|
|
|
), |
145
|
|
|
'customer.telephone' => array( |
146
|
|
|
'label' => 'Customer telephone', |
147
|
|
|
'code' => 'customer.telephone', |
148
|
|
|
'internalcode' => 'lvu."telephone"', |
149
|
|
|
'type' => 'string', |
150
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
151
|
|
|
), |
152
|
|
|
'customer.email' => array( |
153
|
|
|
'label' => 'Customer email', |
154
|
|
|
'code' => 'customer.email', |
155
|
|
|
'internalcode' => 'lvu."email"', |
156
|
|
|
'type' => 'string', |
157
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
158
|
|
|
), |
159
|
|
|
'customer.telefax' => array( |
160
|
|
|
'label' => 'Customer telefax', |
161
|
|
|
'code' => 'customer.telefax', |
162
|
|
|
'internalcode' => 'lvu."telefax"', |
163
|
|
|
'type' => 'string', |
164
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
165
|
|
|
), |
166
|
|
|
'customer.website' => array( |
167
|
|
|
'label' => 'Customer website', |
168
|
|
|
'code' => 'customer.website', |
169
|
|
|
'internalcode' => 'lvu."website"', |
170
|
|
|
'type' => 'string', |
171
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
172
|
|
|
), |
173
|
|
|
'customer.longitude' => array( |
174
|
|
|
'label' => 'Customer longitude', |
175
|
|
|
'code' => 'customer.longitude', |
176
|
|
|
'internalcode' => 'lvu."longitude"', |
177
|
|
|
'type' => 'float', |
178
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_FLOAT, |
179
|
|
|
), |
180
|
|
|
'customer.latitude' => array( |
181
|
|
|
'label' => 'Customer latitude', |
182
|
|
|
'code' => 'customer.latitude', |
183
|
|
|
'internalcode' => 'lvu."latitude"', |
184
|
|
|
'type' => 'float', |
185
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_FLOAT, |
186
|
|
|
), |
187
|
|
|
'customer.birthday' => array( |
188
|
|
|
'label' => 'Customer birthday', |
189
|
|
|
'code' => 'customer.birthday', |
190
|
|
|
'internalcode' => 'lvu."birthday"', |
191
|
|
|
'type' => 'string', |
192
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
193
|
|
|
), |
194
|
|
|
'customer.password'=> array( |
195
|
|
|
'label' => 'Customer password', |
196
|
|
|
'code' => 'customer.password', |
197
|
|
|
'internalcode' => 'lvu."password"', |
198
|
|
|
'type' => 'string', |
199
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
200
|
|
|
), |
201
|
|
|
'customer.status'=> array( |
202
|
|
|
'label' => 'Customer status', |
203
|
|
|
'code' => 'customer.status', |
204
|
|
|
'internalcode' => 'lvu."status"', |
205
|
|
|
'type' => 'integer', |
206
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT |
207
|
|
|
), |
208
|
|
|
'customer.dateverified'=> array( |
209
|
|
|
'label' => 'Customer verification date', |
210
|
|
|
'code' => 'customer.dateverified', |
211
|
|
|
'internalcode' => 'lvu."vdate"', |
212
|
|
|
'type' => 'date', |
213
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
214
|
|
|
), |
215
|
|
|
'customer.ctime'=> array( |
216
|
|
|
'label' => 'Customer creation time', |
217
|
|
|
'code' => 'customer.ctime', |
218
|
|
|
'internalcode' => 'lvu."created_at"', |
219
|
|
|
'type' => 'datetime', |
220
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
221
|
|
|
), |
222
|
|
|
'customer.mtime'=> array( |
223
|
|
|
'label' => 'Customer modification time', |
224
|
|
|
'code' => 'customer.mtime', |
225
|
|
|
'internalcode' => 'lvu."updated_at"', |
226
|
|
|
'type' => 'datetime', |
227
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
228
|
|
|
), |
229
|
|
|
'customer.editor'=> array( |
230
|
|
|
'label'=>'Customer editor', |
231
|
|
|
'code'=>'customer.editor', |
232
|
|
|
'internalcode' => 'lvu."editor"', |
233
|
|
|
'type'=> 'string', |
234
|
|
|
'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
235
|
|
|
), |
236
|
|
|
); |
237
|
|
|
|
238
|
|
|
|
239
|
|
|
/** |
240
|
|
|
* Removes old entries from the storage. |
241
|
|
|
* |
242
|
|
|
* @param array $siteids List of IDs for sites whose entries should be deleted |
243
|
|
|
*/ |
244
|
|
|
public function cleanup( array $siteids ) |
245
|
|
|
{ |
246
|
|
|
$path = 'mshop/customer/manager/submanagers'; |
247
|
|
|
$default = ['address', 'group', 'lists', 'property']; |
248
|
|
|
|
249
|
|
|
foreach( $this->getContext()->getConfig()->get( $path, $default ) as $domain ) { |
250
|
|
|
$this->getObject()->getSubManager( $domain )->cleanup( $siteids ); |
251
|
|
|
} |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* Removes multiple items specified by ids in the array. |
257
|
|
|
* |
258
|
|
|
* @param array $ids List of IDs |
259
|
|
|
*/ |
260
|
|
|
public function deleteItems( array $ids ) |
261
|
|
|
{ |
262
|
|
|
$path = 'mshop/customer/manager/laravel/delete'; |
263
|
|
|
$this->deleteItemsBase( $ids, $path, false ); |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* Returns the list attributes that can be used for searching. |
269
|
|
|
* |
270
|
|
|
* @param boolean $withsub Return also attributes of sub-managers if true |
271
|
|
|
* @return array List of attribute items implementing \Aimeos\MW\Criteria\Attribute\Iface |
272
|
|
|
*/ |
273
|
|
|
public function getSearchAttributes( $withsub = true ) |
274
|
|
|
{ |
275
|
|
|
$path = 'mshop/customer/manager/submanagers'; |
276
|
|
|
$default = ['address', 'group', 'lists', 'property']; |
277
|
|
|
|
278
|
|
|
return $this->getSearchAttributesBase( $this->searchConfig, $path, $default, $withsub ); |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
|
282
|
|
|
/** |
283
|
|
|
* Saves a customer item object. |
284
|
|
|
* |
285
|
|
|
* @param \Aimeos\MShop\Customer\Item\Iface $item Customer item object |
286
|
|
|
* @param boolean $fetch True if the new ID should be returned in the item |
287
|
|
|
* @return \Aimeos\MShop\Common\Item\Iface $item Updated item including the generated ID |
288
|
|
|
*/ |
289
|
|
|
public function saveItem( \Aimeos\MShop\Common\Item\Iface $item, $fetch = true ) |
290
|
|
|
{ |
291
|
|
|
self::checkClass( '\\Aimeos\\MShop\\Customer\\Item\\Iface', $item ); |
292
|
|
|
|
293
|
|
|
if( !$item->isModified() ) |
294
|
|
|
{ |
295
|
|
|
$item = $this->savePropertyItems( $item, 'customer' ); |
296
|
|
|
$item = $this->saveAddressItems( $item, 'customer' ); |
|
|
|
|
297
|
|
|
return $this->saveListItems( $item, 'customer' ); |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
$context = $this->getContext(); |
301
|
|
|
$dbm = $context->getDatabaseManager(); |
302
|
|
|
$dbname = $this->getResourceName(); |
303
|
|
|
$conn = $dbm->acquire( $dbname ); |
304
|
|
|
|
305
|
|
|
try |
306
|
|
|
{ |
307
|
|
|
$id = $item->getId(); |
308
|
|
|
$date = date( 'Y-m-d H:i:s' ); |
309
|
|
|
$billingAddress = $item->getPaymentAddress(); |
|
|
|
|
310
|
|
|
|
311
|
|
|
if( $id === null ) |
312
|
|
|
{ |
313
|
|
|
/** mshop/customer/manager/laravel/insert |
314
|
|
|
* Inserts a new customer record into the database table |
315
|
|
|
* |
316
|
|
|
* Items with no ID yet (i.e. the ID is NULL) will be created in |
317
|
|
|
* the database and the newly created ID retrieved afterwards |
318
|
|
|
* using the "newid" SQL statement. |
319
|
|
|
* |
320
|
|
|
* The SQL statement must be a string suitable for being used as |
321
|
|
|
* prepared statement. It must include question marks for binding |
322
|
|
|
* the values from the customer item to the statement before they are |
323
|
|
|
* sent to the database server. The number of question marks must |
324
|
|
|
* be the same as the number of columns listed in the INSERT |
325
|
|
|
* statement. The order of the columns must correspond to the |
326
|
|
|
* order in the saveItems() method, so the correct values are |
327
|
|
|
* bound to the columns. |
328
|
|
|
* |
329
|
|
|
* The SQL statement should conform to the ANSI standard to be |
330
|
|
|
* compatible with most relational database systems. This also |
331
|
|
|
* includes using double quotes for table and column names. |
332
|
|
|
* |
333
|
|
|
* @param string SQL statement for inserting records |
334
|
|
|
* @since 2015.01 |
335
|
|
|
* @category Developer |
336
|
|
|
* @see mshop/customer/manager/laravel/update |
337
|
|
|
* @see mshop/customer/manager/laravel/newid |
338
|
|
|
* @see mshop/customer/manager/laravel/delete |
339
|
|
|
* @see mshop/customer/manager/laravel/search |
340
|
|
|
* @see mshop/customer/manager/laravel/count |
341
|
|
|
*/ |
342
|
|
|
$path = 'mshop/customer/manager/laravel/insert'; |
343
|
|
|
} |
344
|
|
|
else |
345
|
|
|
{ |
346
|
|
|
/** mshop/customer/manager/laravel/update |
347
|
|
|
* Updates an existing customer record in the database |
348
|
|
|
* |
349
|
|
|
* Items which already have an ID (i.e. the ID is not NULL) will |
350
|
|
|
* be updated in the database. |
351
|
|
|
* |
352
|
|
|
* The SQL statement must be a string suitable for being used as |
353
|
|
|
* prepared statement. It must include question marks for binding |
354
|
|
|
* the values from the customer item to the statement before they are |
355
|
|
|
* sent to the database server. The order of the columns must |
356
|
|
|
* correspond to the order in the saveItems() method, so the |
357
|
|
|
* correct values are bound to the columns. |
358
|
|
|
* |
359
|
|
|
* The SQL statement should conform to the ANSI standard to be |
360
|
|
|
* compatible with most relational database systems. This also |
361
|
|
|
* includes using double quotes for table and column names. |
362
|
|
|
* |
363
|
|
|
* @param string SQL statement for updating records |
364
|
|
|
* @since 2015.01 |
365
|
|
|
* @category Developer |
366
|
|
|
* @see mshop/customer/manager/laravel/insert |
367
|
|
|
* @see mshop/customer/manager/laravel/newid |
368
|
|
|
* @see mshop/customer/manager/laravel/delete |
369
|
|
|
* @see mshop/customer/manager/laravel/search |
370
|
|
|
* @see mshop/customer/manager/laravel/count |
371
|
|
|
*/ |
372
|
|
|
$path = 'mshop/customer/manager/laravel/update'; |
373
|
|
|
} |
374
|
|
|
|
375
|
|
|
$stmt = $this->getCachedStatement( $conn, $path ); |
376
|
|
|
|
377
|
|
|
$stmt->bind( 1, $context->getLocale()->getSiteId(), \Aimeos\MW\DB\Statement\Base::PARAM_INT ); |
378
|
|
|
$stmt->bind( 2, $item->getCode() ); |
|
|
|
|
379
|
|
|
$stmt->bind( 3, $billingAddress->getCompany() ); |
380
|
|
|
$stmt->bind( 4, $billingAddress->getVatID() ); |
381
|
|
|
$stmt->bind( 5, $billingAddress->getSalutation() ); |
382
|
|
|
$stmt->bind( 6, $billingAddress->getTitle() ); |
383
|
|
|
$stmt->bind( 7, $billingAddress->getFirstname() ); |
384
|
|
|
$stmt->bind( 8, $billingAddress->getLastname() ); |
385
|
|
|
$stmt->bind( 9, $billingAddress->getAddress1() ); |
386
|
|
|
$stmt->bind( 10, $billingAddress->getAddress2() ); |
387
|
|
|
$stmt->bind( 11, $billingAddress->getAddress3() ); |
388
|
|
|
$stmt->bind( 12, $billingAddress->getPostal() ); |
389
|
|
|
$stmt->bind( 13, $billingAddress->getCity() ); |
390
|
|
|
$stmt->bind( 14, $billingAddress->getState() ); |
391
|
|
|
$stmt->bind( 15, $billingAddress->getCountryId() ); |
392
|
|
|
$stmt->bind( 16, $billingAddress->getLanguageId() ); |
393
|
|
|
$stmt->bind( 17, $billingAddress->getTelephone() ); |
394
|
|
|
$stmt->bind( 18, $billingAddress->getTelefax() ); |
395
|
|
|
$stmt->bind( 19, $billingAddress->getWebsite() ); |
396
|
|
|
$stmt->bind( 20, $billingAddress->getEmail() ); |
397
|
|
|
$stmt->bind( 21, $billingAddress->getLongitude(), \Aimeos\MW\DB\Statement\Base::PARAM_FLOAT ); |
398
|
|
|
$stmt->bind( 22, $billingAddress->getLatitude(), \Aimeos\MW\DB\Statement\Base::PARAM_FLOAT ); |
399
|
|
|
$stmt->bind( 23, $item->getLabel() ); |
|
|
|
|
400
|
|
|
$stmt->bind( 24, $item->getBirthday() ); |
|
|
|
|
401
|
|
|
$stmt->bind( 25, $item->getStatus(), \Aimeos\MW\DB\Statement\Base::PARAM_INT ); |
|
|
|
|
402
|
|
|
$stmt->bind( 26, $item->getDateVerified() ); |
|
|
|
|
403
|
|
|
$stmt->bind( 27, $item->getPassword() ); |
|
|
|
|
404
|
|
|
$stmt->bind( 28, $date ); // Modification time |
405
|
|
|
$stmt->bind( 29, $context->getEditor() ); |
406
|
|
|
|
407
|
|
|
if( $id !== null ) { |
408
|
|
|
$stmt->bind( 30, $id, \Aimeos\MW\DB\Statement\Base::PARAM_INT ); |
409
|
|
|
$item->setId( $id ); |
410
|
|
|
} else { |
411
|
|
|
$stmt->bind( 30, $date ); // Creation time |
412
|
|
|
} |
413
|
|
|
|
414
|
|
|
$stmt->execute()->finish(); |
415
|
|
|
|
416
|
|
|
if( $id === null && $fetch === true ) |
417
|
|
|
{ |
418
|
|
|
/** mshop/customer/manager/laravel/newid |
419
|
|
|
* Retrieves the ID generated by the database when inserting a new record |
420
|
|
|
* |
421
|
|
|
* As soon as a new record is inserted into the database table, |
422
|
|
|
* the database server generates a new and unique identifier for |
423
|
|
|
* that record. This ID can be used for retrieving, updating and |
424
|
|
|
* deleting that specific record from the table again. |
425
|
|
|
* |
426
|
|
|
* For MySQL: |
427
|
|
|
* SELECT LAST_INSERT_ID() |
428
|
|
|
* For PostgreSQL: |
429
|
|
|
* SELECT currval('seq_mcus_id') |
430
|
|
|
* For SQL Server: |
431
|
|
|
* SELECT SCOPE_IDENTITY() |
432
|
|
|
* For Oracle: |
433
|
|
|
* SELECT "seq_mcus_id".CURRVAL FROM DUAL |
434
|
|
|
* |
435
|
|
|
* There's no way to retrive the new ID by a SQL statements that |
436
|
|
|
* fits for most database servers as they implement their own |
437
|
|
|
* specific way. |
438
|
|
|
* |
439
|
|
|
* @param string SQL statement for retrieving the last inserted record ID |
440
|
|
|
* @since 2015.01 |
441
|
|
|
* @category Developer |
442
|
|
|
* @see mshop/customer/manager/laravel/insert |
443
|
|
|
* @see mshop/customer/manager/laravel/update |
444
|
|
|
* @see mshop/customer/manager/laravel/delete |
445
|
|
|
* @see mshop/customer/manager/laravel/search |
446
|
|
|
* @see mshop/customer/manager/laravel/count |
447
|
|
|
*/ |
448
|
|
|
$path = 'mshop/customer/manager/laravel/newid'; |
449
|
|
|
$item->setId( $this->newId( $conn, $path ) ); |
450
|
|
|
} |
451
|
|
|
|
452
|
|
|
$dbm->release( $conn, $dbname ); |
453
|
|
|
} |
454
|
|
|
catch( \Exception $e ) |
455
|
|
|
{ |
456
|
|
|
$dbm->release( $conn, $dbname ); |
457
|
|
|
throw $e; |
458
|
|
|
} |
459
|
|
|
|
460
|
|
|
$this->addGroups( $item ); |
461
|
|
|
|
462
|
|
|
$item = $this->savePropertyItems( $item, 'customer' ); |
463
|
|
|
$item = $this->saveAddressItems( $item, 'customer' ); |
464
|
|
|
return $this->saveListItems( $item, 'customer' ); |
465
|
|
|
} |
466
|
|
|
|
467
|
|
|
|
468
|
|
|
/** |
469
|
|
|
* Returns the item objects matched by the given search criteria. |
470
|
|
|
* |
471
|
|
|
* @param \Aimeos\MW\Criteria\Iface $search Search criteria object |
472
|
|
|
* @param integer &$total Number of items that are available in total |
473
|
|
|
* @return array List of items implementing \Aimeos\MShop\Customer\Item\Iface |
474
|
|
|
* @throws \Aimeos\MShop\Customer\Exception If creating items failed |
475
|
|
|
*/ |
476
|
|
|
public function searchItems( \Aimeos\MW\Criteria\Iface $search, array $ref = [], &$total = null ) |
477
|
|
|
{ |
478
|
|
|
$dbm = $this->getContext()->getDatabaseManager(); |
479
|
|
|
$dbname = $this->getResourceName(); |
480
|
|
|
$conn = $dbm->acquire( $dbname ); |
481
|
|
|
$map = []; |
482
|
|
|
|
483
|
|
|
try |
484
|
|
|
{ |
485
|
|
|
$level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL; |
486
|
|
|
$cfgPathSearch = 'mshop/customer/manager/laravel/search'; |
487
|
|
|
$cfgPathCount = 'mshop/customer/manager/laravel/count'; |
488
|
|
|
$required = array( 'customer' ); |
489
|
|
|
|
490
|
|
|
$results = $this->searchItemsBase( $conn, $search, $cfgPathSearch, $cfgPathCount, $required, $total, $level ); |
491
|
|
|
while( ( $row = $results->fetch() ) !== false ) { |
492
|
|
|
$map[ $row['customer.id'] ] = $row; |
493
|
|
|
} |
494
|
|
|
|
495
|
|
|
$dbm->release( $conn, $dbname ); |
496
|
|
|
} |
497
|
|
|
catch( \Exception $e ) |
498
|
|
|
{ |
499
|
|
|
$dbm->release( $conn, $dbname ); |
500
|
|
|
throw $e; |
501
|
|
|
} |
502
|
|
|
|
503
|
|
|
$addrItems = []; |
504
|
|
|
if( in_array( 'customer/address', $ref, true ) ) { |
505
|
|
|
$addrItems = $this->getAddressItems( array_keys( $map ), 'customer' ); |
506
|
|
|
} |
507
|
|
|
|
508
|
|
|
$propItems = []; |
509
|
|
|
if( in_array( 'customer/property', $ref, true ) ) { |
510
|
|
|
$propItems = $this->getPropertyItems( array_keys( $map ), 'customer' ); |
511
|
|
|
} |
512
|
|
|
|
513
|
|
|
return $this->buildItems( $map, $ref, 'customer', $addrItems, $propItems ); |
514
|
|
|
} |
515
|
|
|
|
516
|
|
|
|
517
|
|
|
/** |
518
|
|
|
* Returns a new manager for customer extensions |
519
|
|
|
* |
520
|
|
|
* @param string $manager Name of the sub manager type in lower case |
521
|
|
|
* @param string|null $name Name of the implementation, will be from configuration (or Default) if null |
522
|
|
|
* @return mixed Manager for different extensions, e.g stock, tags, locations, etc. |
523
|
|
|
*/ |
524
|
|
|
public function getSubManager( $manager, $name = null ) |
525
|
|
|
{ |
526
|
|
|
return $this->getSubManagerBase( 'customer', $manager, ( $name === null ? 'Laravel' : $name ) ); |
527
|
|
|
} |
528
|
|
|
} |
529
|
|
|
|