@@ -499,7 +499,7 @@ |
||
499 | 499 | * |
500 | 500 | * @param array $products List of products items implementing \Aimeos\MShop\Product\Item\Iface |
501 | 501 | * @param array $data Associative list of import data as index/value pairs |
502 | - * @param array $mappings Associative list of positions and domain item keys |
|
502 | + * @param array $mapping Associative list of positions and domain item keys |
|
503 | 503 | * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor Processor object |
504 | 504 | * @param boolean $strict Log columns not mapped or silently ignore them |
505 | 505 | * @return integer Number of products that couldn't be imported |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | * @see controller/jobs/product/import/csv/container/type |
426 | 426 | * @see controller/jobs/product/import/csv/container/content |
427 | 427 | * @see controller/jobs/product/import/csv/container/options |
428 | - */ |
|
428 | + */ |
|
429 | 429 | $location = $config->get( 'controller/jobs/product/import/csv/location', '.' ); |
430 | 430 | |
431 | 431 | /** controller/jobs/product/import/csv/container/type |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | * @see controller/jobs/product/import/csv/location |
449 | 449 | * @see controller/jobs/product/import/csv/container/content |
450 | 450 | * @see controller/jobs/product/import/csv/container/options |
451 | - */ |
|
451 | + */ |
|
452 | 452 | $container = $config->get( 'controller/jobs/product/import/csv/container/type', 'Directory' ); |
453 | 453 | |
454 | 454 | /** controller/jobs/product/import/csv/container/content |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | * @see controller/jobs/product/import/csv/location |
470 | 470 | * @see controller/jobs/product/import/csv/container/type |
471 | 471 | * @see controller/jobs/product/import/csv/container/options |
472 | - */ |
|
472 | + */ |
|
473 | 473 | $content = $config->get( 'controller/jobs/product/import/csv/container/content', 'CSV' ); |
474 | 474 | |
475 | 475 | /** controller/jobs/product/import/csv/container/options |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | * @see controller/jobs/product/import/csv/location |
488 | 488 | * @see controller/jobs/product/import/csv/container/content |
489 | 489 | * @see controller/jobs/product/import/csv/container/type |
490 | - */ |
|
490 | + */ |
|
491 | 491 | $options = $config->get( 'controller/jobs/product/import/csv/container/options', array() ); |
492 | 492 | |
493 | 493 | return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options ); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function getName() |
30 | 30 | { |
31 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Product import CSV' ); |
|
31 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Product import CSV'); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function getDescription() |
41 | 41 | { |
42 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Imports new and updates existing products from CSV files' ); |
|
42 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Imports new and updates existing products from CSV files'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $context = $this->getContext(); |
55 | 55 | $config = $context->getConfig(); |
56 | 56 | $logger = $context->getLogger(); |
57 | - $domains = array( 'attribute', 'media', 'price', 'product', 'text' ); |
|
57 | + $domains = array('attribute', 'media', 'price', 'product', 'text'); |
|
58 | 58 | $mappings = $this->getDefaultMapping(); |
59 | 59 | |
60 | 60 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @see controller/common/product/import/csv/converter |
75 | 75 | * @see controller/common/product/import/csv/max-size |
76 | 76 | */ |
77 | - $domains = $config->get( 'controller/common/product/import/csv/domains', $domains ); |
|
77 | + $domains = $config->get('controller/common/product/import/csv/domains', $domains); |
|
78 | 78 | |
79 | 79 | /** controller/jobs/product/import/csv/domains |
80 | 80 | * List of item domain names that should be retrieved along with the product items |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @see controller/jobs/product/import/csv/backup |
95 | 95 | * @see controller/common/product/import/csv/max-size |
96 | 96 | */ |
97 | - $domains = $config->get( 'controller/jobs/product/import/csv/domains', $domains ); |
|
97 | + $domains = $config->get('controller/jobs/product/import/csv/domains', $domains); |
|
98 | 98 | |
99 | 99 | |
100 | 100 | /** controller/common/product/import/csv/mapping |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @see controller/common/product/import/csv/converter |
123 | 123 | * @see controller/common/product/import/csv/max-size |
124 | 124 | */ |
125 | - $mappings = $config->get( 'controller/common/product/import/csv/mapping', $mappings ); |
|
125 | + $mappings = $config->get('controller/common/product/import/csv/mapping', $mappings); |
|
126 | 126 | |
127 | 127 | /** controller/jobs/product/import/csv/mapping |
128 | 128 | * List of mappings between the position in the CSV file and item keys |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @see controller/jobs/product/import/csv/backup |
143 | 143 | * @see controller/common/product/import/csv/max-size |
144 | 144 | */ |
145 | - $mappings = $config->get( 'controller/jobs/product/import/csv/mapping', $mappings ); |
|
145 | + $mappings = $config->get('controller/jobs/product/import/csv/mapping', $mappings); |
|
146 | 146 | |
147 | 147 | |
148 | 148 | /** controller/common/product/import/csv/converter |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * @see controller/common/product/import/csv/mapping |
185 | 185 | * @see controller/common/product/import/csv/max-size |
186 | 186 | */ |
187 | - $converters = $config->get( 'controller/common/product/import/csv/converter', array() ); |
|
187 | + $converters = $config->get('controller/common/product/import/csv/converter', array()); |
|
188 | 188 | |
189 | 189 | /** controller/jobs/product/import/csv/converter |
190 | 190 | * List of converter names for the values at the position in the CSV file |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @see controller/jobs/product/import/csv/backup |
205 | 205 | * @see controller/common/product/import/csv/max-size |
206 | 206 | */ |
207 | - $converters = $config->get( 'controller/jobs/product/import/csv/converter', $converters ); |
|
207 | + $converters = $config->get('controller/jobs/product/import/csv/converter', $converters); |
|
208 | 208 | |
209 | 209 | |
210 | 210 | /** controller/common/product/import/csv/max-size |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @see controller/common/product/import/csv/mapping |
225 | 225 | * @see controller/common/product/import/csv/converter |
226 | 226 | */ |
227 | - $maxcnt = (int) $config->get( 'controller/common/product/import/csv/max-size', 1000 ); |
|
227 | + $maxcnt = (int) $config->get('controller/common/product/import/csv/max-size', 1000); |
|
228 | 228 | |
229 | 229 | |
230 | 230 | /** controller/jobs/product/import/csv/skip-lines |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @see controller/jobs/product/import/csv/backup |
247 | 247 | * @see controller/common/product/import/csv/max-size |
248 | 248 | */ |
249 | - $skiplines = (int) $config->get( 'controller/jobs/product/import/csv/skip-lines', 0 ); |
|
249 | + $skiplines = (int) $config->get('controller/jobs/product/import/csv/skip-lines', 0); |
|
250 | 250 | |
251 | 251 | |
252 | 252 | /** controller/jobs/product/import/csv/strict |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @see controller/jobs/product/import/csv/backup |
271 | 271 | * @see controller/common/product/import/csv/max-size |
272 | 272 | */ |
273 | - $strict = (bool) $config->get( 'controller/jobs/product/import/csv/strict', true ); |
|
273 | + $strict = (bool) $config->get('controller/jobs/product/import/csv/strict', true); |
|
274 | 274 | |
275 | 275 | |
276 | 276 | /** controller/jobs/product/import/csv/backup |
@@ -303,74 +303,74 @@ discard block |
||
303 | 303 | * @see controller/jobs/product/import/csv/strict |
304 | 304 | * @see controller/common/product/import/csv/max-size |
305 | 305 | */ |
306 | - $backup = $config->get( 'controller/jobs/product/import/csv/backup' ); |
|
306 | + $backup = $config->get('controller/jobs/product/import/csv/backup'); |
|
307 | 307 | |
308 | 308 | |
309 | - if( !isset( $mappings['item'] ) || !is_array( $mappings['item'] ) ) |
|
309 | + if (!isset($mappings['item']) || !is_array($mappings['item'])) |
|
310 | 310 | { |
311 | - $msg = sprintf( 'Required mapping key "%1$s" is missing or contains no array', 'item' ); |
|
312 | - throw new \Aimeos\Controller\Jobs\Exception( $msg ); |
|
311 | + $msg = sprintf('Required mapping key "%1$s" is missing or contains no array', 'item'); |
|
312 | + throw new \Aimeos\Controller\Jobs\Exception($msg); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | try |
316 | 316 | { |
317 | 317 | $procMappings = $mappings; |
318 | - unset( $procMappings['item'] ); |
|
318 | + unset($procMappings['item']); |
|
319 | 319 | |
320 | - $codePos = $this->getCodePosition( $mappings['item'] ); |
|
321 | - $convlist = $this->getConverterList( $converters ); |
|
322 | - $processor = $this->getProcessors( $procMappings ); |
|
320 | + $codePos = $this->getCodePosition($mappings['item']); |
|
321 | + $convlist = $this->getConverterList($converters); |
|
322 | + $processor = $this->getProcessors($procMappings); |
|
323 | 323 | $container = $this->getContainer(); |
324 | 324 | $path = $container->getName(); |
325 | 325 | |
326 | - $msg = sprintf( 'Started product import from "%1$s" (%2$s)', $path, __CLASS__ ); |
|
327 | - $logger->log( $msg, \Aimeos\MW\Logger\Base::NOTICE ); |
|
326 | + $msg = sprintf('Started product import from "%1$s" (%2$s)', $path, __CLASS__); |
|
327 | + $logger->log($msg, \Aimeos\MW\Logger\Base::NOTICE); |
|
328 | 328 | |
329 | - foreach( $container as $content ) |
|
329 | + foreach ($container as $content) |
|
330 | 330 | { |
331 | 331 | $name = $content->getName(); |
332 | 332 | |
333 | - for( $i = 0; $i < $skiplines; $i++ ) { |
|
333 | + for ($i = 0; $i < $skiplines; $i++) { |
|
334 | 334 | $content->next(); |
335 | 335 | } |
336 | 336 | |
337 | - while( ( $data = $this->getData( $content, $maxcnt, $codePos ) ) !== array() ) |
|
337 | + while (($data = $this->getData($content, $maxcnt, $codePos)) !== array()) |
|
338 | 338 | { |
339 | - $data = $this->convertData( $convlist, $data ); |
|
340 | - $products = $this->getProducts( array_keys( $data ), $domains ); |
|
341 | - $errcnt = $this->import( $products, $data, $mappings['item'], $processor, $strict ); |
|
342 | - $chunkcnt = count( $data ); |
|
339 | + $data = $this->convertData($convlist, $data); |
|
340 | + $products = $this->getProducts(array_keys($data), $domains); |
|
341 | + $errcnt = $this->import($products, $data, $mappings['item'], $processor, $strict); |
|
342 | + $chunkcnt = count($data); |
|
343 | 343 | |
344 | 344 | $msg = 'Imported product lines from "%1$s": %2$d/%3$d (%4$s)'; |
345 | - $logger->log( sprintf( $msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE ); |
|
345 | + $logger->log(sprintf($msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE); |
|
346 | 346 | |
347 | 347 | $errors += $errcnt; |
348 | 348 | $total += $chunkcnt; |
349 | - unset( $products, $data ); |
|
349 | + unset($products, $data); |
|
350 | 350 | } |
351 | 351 | } |
352 | 352 | |
353 | 353 | $container->close(); |
354 | 354 | } |
355 | - catch( \Exception $e ) |
|
355 | + catch (\Exception $e) |
|
356 | 356 | { |
357 | - $logger->log( 'Product import error: ' . $e->getMessage() ); |
|
358 | - $logger->log( $e->getTraceAsString() ); |
|
357 | + $logger->log('Product import error: ' . $e->getMessage()); |
|
358 | + $logger->log($e->getTraceAsString()); |
|
359 | 359 | |
360 | - throw new \Aimeos\Controller\Jobs\Exception( $e->getMessage() ); |
|
360 | + throw new \Aimeos\Controller\Jobs\Exception($e->getMessage()); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | $msg = 'Finished product import from "%1$s": %2$d successful, %3$s errors, %4$s total (%5$s)'; |
364 | - $logger->log( sprintf( $msg, $path, $total - $errors, $errors, $total, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE ); |
|
364 | + $logger->log(sprintf($msg, $path, $total - $errors, $errors, $total, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE); |
|
365 | 365 | |
366 | - if( $errors > 0 ) |
|
366 | + if ($errors > 0) |
|
367 | 367 | { |
368 | - $msg = sprintf( 'Invalid product lines in "%1$s": %2$d/%3$d', $path, $errors, $total ); |
|
369 | - throw new \Aimeos\Controller\Jobs\Exception( $msg ); |
|
368 | + $msg = sprintf('Invalid product lines in "%1$s": %2$d/%3$d', $path, $errors, $total); |
|
369 | + throw new \Aimeos\Controller\Jobs\Exception($msg); |
|
370 | 370 | } |
371 | 371 | |
372 | - if( !empty( $backup ) && @rename( $path, strftime( $backup ) ) === false ) { |
|
373 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Unable to move imported file' ) ); |
|
372 | + if (!empty($backup) && @rename($path, strftime($backup)) === false) { |
|
373 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Unable to move imported file')); |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
@@ -382,16 +382,16 @@ discard block |
||
382 | 382 | * @return integer Position of the "product.code" column |
383 | 383 | * @throws \Aimeos\Controller\Jobs\Exception If no mapping for "product.code" is found |
384 | 384 | */ |
385 | - protected function getCodePosition( array $mapping ) |
|
385 | + protected function getCodePosition(array $mapping) |
|
386 | 386 | { |
387 | - foreach( $mapping as $pos => $key ) |
|
387 | + foreach ($mapping as $pos => $key) |
|
388 | 388 | { |
389 | - if( $key === 'product.code' ) { |
|
389 | + if ($key === 'product.code') { |
|
390 | 390 | return $pos; |
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
394 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No "product.code" column in CSV mapping found' ) ); |
|
394 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('No "product.code" column in CSV mapping found')); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * @see controller/jobs/product/import/csv/container/content |
427 | 427 | * @see controller/jobs/product/import/csv/container/options |
428 | 428 | */ |
429 | - $location = $config->get( 'controller/jobs/product/import/csv/location', '.' ); |
|
429 | + $location = $config->get('controller/jobs/product/import/csv/location', '.'); |
|
430 | 430 | |
431 | 431 | /** controller/jobs/product/import/csv/container/type |
432 | 432 | * Nave of the container type to read the data from |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | * @see controller/jobs/product/import/csv/container/content |
450 | 450 | * @see controller/jobs/product/import/csv/container/options |
451 | 451 | */ |
452 | - $container = $config->get( 'controller/jobs/product/import/csv/container/type', 'Directory' ); |
|
452 | + $container = $config->get('controller/jobs/product/import/csv/container/type', 'Directory'); |
|
453 | 453 | |
454 | 454 | /** controller/jobs/product/import/csv/container/content |
455 | 455 | * Name of the content type inside the container to read the data from |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | * @see controller/jobs/product/import/csv/container/type |
471 | 471 | * @see controller/jobs/product/import/csv/container/options |
472 | 472 | */ |
473 | - $content = $config->get( 'controller/jobs/product/import/csv/container/content', 'CSV' ); |
|
473 | + $content = $config->get('controller/jobs/product/import/csv/container/content', 'CSV'); |
|
474 | 474 | |
475 | 475 | /** controller/jobs/product/import/csv/container/options |
476 | 476 | * List of file container options for the product import files |
@@ -488,9 +488,9 @@ discard block |
||
488 | 488 | * @see controller/jobs/product/import/csv/container/content |
489 | 489 | * @see controller/jobs/product/import/csv/container/type |
490 | 490 | */ |
491 | - $options = $config->get( 'controller/jobs/product/import/csv/container/options', array() ); |
|
491 | + $options = $config->get('controller/jobs/product/import/csv/container/options', array()); |
|
492 | 492 | |
493 | - return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options ); |
|
493 | + return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | |
@@ -505,14 +505,14 @@ discard block |
||
505 | 505 | * @return integer Number of products that couldn't be imported |
506 | 506 | * @throws \Aimeos\Controller\Jobs\Exception |
507 | 507 | */ |
508 | - protected function import( array $products, array $data, array $mapping, |
|
509 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor, $strict ) |
|
508 | + protected function import(array $products, array $data, array $mapping, |
|
509 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor, $strict) |
|
510 | 510 | { |
511 | 511 | $errors = 0; |
512 | 512 | $context = $this->getContext(); |
513 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
513 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
514 | 514 | |
515 | - foreach( $data as $code => $list ) |
|
515 | + foreach ($data as $code => $list) |
|
516 | 516 | { |
517 | 517 | $remaining = array(); |
518 | 518 | |
@@ -520,36 +520,36 @@ discard block |
||
520 | 520 | |
521 | 521 | try |
522 | 522 | { |
523 | - if( isset( $products[$code] ) ) { |
|
523 | + if (isset($products[$code])) { |
|
524 | 524 | $product = $products[$code]; |
525 | 525 | } else { |
526 | 526 | $product = $manager->createItem(); |
527 | 527 | } |
528 | 528 | |
529 | - $map = $this->getMappedData( $mapping, $list ); |
|
529 | + $map = $this->getMappedData($mapping, $list); |
|
530 | 530 | |
531 | - $typecode = ( isset( $map['product.type'] ) ? $map['product.type'] : 'default' ); |
|
532 | - $map['product.typeid'] = $this->getTypeId( 'product/type', 'product', $typecode ); |
|
531 | + $typecode = (isset($map['product.type']) ? $map['product.type'] : 'default'); |
|
532 | + $map['product.typeid'] = $this->getTypeId('product/type', 'product', $typecode); |
|
533 | 533 | |
534 | - $product->fromArray( $this->addItemDefaults( $map ) ); |
|
535 | - $manager->saveItem( $product ); |
|
534 | + $product->fromArray($this->addItemDefaults($map)); |
|
535 | + $manager->saveItem($product); |
|
536 | 536 | |
537 | - $remaining = $processor->process( $product, $list ); |
|
537 | + $remaining = $processor->process($product, $list); |
|
538 | 538 | |
539 | 539 | $manager->commit(); |
540 | 540 | } |
541 | - catch( \Exception $e ) |
|
541 | + catch (\Exception $e) |
|
542 | 542 | { |
543 | 543 | $manager->rollback(); |
544 | 544 | |
545 | - $msg = sprintf( 'Unable to import product with code "%1$s": %2$s', $code, $e->getMessage() ); |
|
546 | - $context->getLogger()->log( $msg ); |
|
545 | + $msg = sprintf('Unable to import product with code "%1$s": %2$s', $code, $e->getMessage()); |
|
546 | + $context->getLogger()->log($msg); |
|
547 | 547 | |
548 | 548 | $errors++; |
549 | 549 | } |
550 | 550 | |
551 | - if( $strict && !empty( $remaining ) ) { |
|
552 | - $context->getLogger()->log( 'Not imported: ' . print_r( $remaining, true ) ); |
|
551 | + if ($strict && !empty($remaining)) { |
|
552 | + $context->getLogger()->log('Not imported: ' . print_r($remaining, true)); |
|
553 | 553 | } |
554 | 554 | } |
555 | 555 | |
@@ -563,9 +563,9 @@ discard block |
||
563 | 563 | * @param array $list Associative list of domain item keys and their values, e.g. "product.status" => 1 |
564 | 564 | * @return array Given associative list enriched by default values if they were not already set |
565 | 565 | */ |
566 | - protected function addItemDefaults( array $list ) |
|
566 | + protected function addItemDefaults(array $list) |
|
567 | 567 | { |
568 | - if( !isset( $list['product.status'] ) ) { |
|
568 | + if (!isset($list['product.status'])) { |
|
569 | 569 | $list['product.status'] = 1; |
570 | 570 | } |
571 | 571 |
@@ -351,8 +351,7 @@ discard block |
||
351 | 351 | } |
352 | 352 | |
353 | 353 | $container->close(); |
354 | - } |
|
355 | - catch( \Exception $e ) |
|
354 | + } catch( \Exception $e ) |
|
356 | 355 | { |
357 | 356 | $logger->log( 'Product import error: ' . $e->getMessage() ); |
358 | 357 | $logger->log( $e->getTraceAsString() ); |
@@ -537,8 +536,7 @@ discard block |
||
537 | 536 | $remaining = $processor->process( $product, $list ); |
538 | 537 | |
539 | 538 | $manager->commit(); |
540 | - } |
|
541 | - catch( \Exception $e ) |
|
539 | + } catch( \Exception $e ) |
|
542 | 540 | { |
543 | 541 | $manager->rollback(); |
544 | 542 |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
43 | 43 | * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor |
44 | 44 | */ |
45 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
46 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null ) |
|
45 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
46 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null) |
|
47 | 47 | { |
48 | - parent::__construct( $context, $mapping, $object ); |
|
48 | + parent::__construct($context, $mapping, $object); |
|
49 | 49 | |
50 | - $this->cache = $this->getCache( 'warehouse' ); |
|
50 | + $this->cache = $this->getCache('warehouse'); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -58,55 +58,55 @@ discard block |
||
58 | 58 | * @param array $data List of CSV fields with position as key and data as value |
59 | 59 | * @return array List of data which hasn't been imported |
60 | 60 | */ |
61 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
61 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
62 | 62 | { |
63 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/stock' ); |
|
63 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/stock'); |
|
64 | 64 | $manager->begin(); |
65 | 65 | |
66 | 66 | try |
67 | 67 | { |
68 | 68 | $pos = 0; |
69 | 69 | $delete = array(); |
70 | - $map = $this->getMappedChunk( $data ); |
|
71 | - $items = $this->getStockItems( $product->getId() ); |
|
70 | + $map = $this->getMappedChunk($data); |
|
71 | + $items = $this->getStockItems($product->getId()); |
|
72 | 72 | |
73 | - foreach( $map as $pos => $list ) |
|
73 | + foreach ($map as $pos => $list) |
|
74 | 74 | { |
75 | - if( !array_key_exists( 'product.stock.stocklevel', $list ) ) { |
|
75 | + if (!array_key_exists('product.stock.stocklevel', $list)) { |
|
76 | 76 | continue; |
77 | 77 | } |
78 | 78 | |
79 | - $whcode = ( isset( $list['product.stock.warehouse'] ) ? $list['product.stock.warehouse'] : 'default' ); |
|
79 | + $whcode = (isset($list['product.stock.warehouse']) ? $list['product.stock.warehouse'] : 'default'); |
|
80 | 80 | |
81 | - if( !isset( $list['product.stock.warehouseid'] ) ) { |
|
82 | - $list['product.stock.warehouseid'] = $this->cache->get( $whcode ); |
|
81 | + if (!isset($list['product.stock.warehouseid'])) { |
|
82 | + $list['product.stock.warehouseid'] = $this->cache->get($whcode); |
|
83 | 83 | } |
84 | 84 | |
85 | - if( isset( $list['product.stock.dateback'] ) && $list['product.stock.dateback'] === '' ) { |
|
85 | + if (isset($list['product.stock.dateback']) && $list['product.stock.dateback'] === '') { |
|
86 | 86 | $list['product.stock.dateback'] = null; |
87 | 87 | } |
88 | 88 | |
89 | - if( $list['product.stock.stocklevel'] === '' ) { |
|
89 | + if ($list['product.stock.stocklevel'] === '') { |
|
90 | 90 | $list['product.stock.stocklevel'] = null; |
91 | 91 | } |
92 | 92 | |
93 | 93 | $list['product.stock.parentid'] = $product->getId(); |
94 | 94 | |
95 | - if( ( $item = array_pop( $items ) ) === null ) { |
|
95 | + if (($item = array_pop($items)) === null) { |
|
96 | 96 | $item = $manager->createItem(); |
97 | 97 | } |
98 | 98 | |
99 | - $item->fromArray( $list ); |
|
100 | - $manager->saveItem( $item ); |
|
99 | + $item->fromArray($list); |
|
100 | + $manager->saveItem($item); |
|
101 | 101 | } |
102 | 102 | |
103 | - $manager->deleteItems( array_keys( $items ) ); |
|
103 | + $manager->deleteItems(array_keys($items)); |
|
104 | 104 | |
105 | - $remaining = $this->getObject()->process( $product, $data ); |
|
105 | + $remaining = $this->getObject()->process($product, $data); |
|
106 | 106 | |
107 | 107 | $manager->commit(); |
108 | 108 | } |
109 | - catch( \Exception $e ) |
|
109 | + catch (\Exception $e) |
|
110 | 110 | { |
111 | 111 | $manager->rollback(); |
112 | 112 | throw $e; |
@@ -122,13 +122,13 @@ discard block |
||
122 | 122 | * @param string $prodid Unique product ID |
123 | 123 | * @return array Associative list of product stock items |
124 | 124 | */ |
125 | - protected function getStockItems( $prodid ) |
|
125 | + protected function getStockItems($prodid) |
|
126 | 126 | { |
127 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/stock' ); |
|
127 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/stock'); |
|
128 | 128 | |
129 | 129 | $search = $manager->createSearch(); |
130 | - $search->setConditions( $search->compare( '==', 'product.stock.parentid', $prodid ) ); |
|
130 | + $search->setConditions($search->compare('==', 'product.stock.parentid', $prodid)); |
|
131 | 131 | |
132 | - return $manager->searchItems( $search ); |
|
132 | + return $manager->searchItems($search); |
|
133 | 133 | } |
134 | 134 | } |
@@ -105,8 +105,7 @@ |
||
105 | 105 | $remaining = $this->getObject()->process( $product, $data ); |
106 | 106 | |
107 | 107 | $manager->commit(); |
108 | - } |
|
109 | - catch( \Exception $e ) |
|
108 | + } catch( \Exception $e ) |
|
110 | 109 | { |
111 | 110 | $manager->rollback(); |
112 | 111 | throw $e; |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
28 | 28 | * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor Decorated processor |
29 | 29 | */ |
30 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
31 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor = null ) |
|
30 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
31 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor = null) |
|
32 | 32 | { |
33 | 33 | } |
34 | 34 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param array $data List of CSV fields with position as key and data as value |
41 | 41 | * @return array List of data which hasn't been imported |
42 | 42 | */ |
43 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
43 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
44 | 44 | { |
45 | 45 | return $data; |
46 | 46 | } |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
44 | 44 | * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor |
45 | 45 | */ |
46 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
47 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null ) |
|
46 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
47 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null) |
|
48 | 48 | { |
49 | - parent::__construct( $context, $mapping, $object ); |
|
49 | + parent::__construct($context, $mapping, $object); |
|
50 | 50 | |
51 | 51 | /** controller/common/product/import/csv/processor/attribute/listtypes |
52 | 52 | * Names of the product list types for attributes that are updated or removed |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | * @see controller/common/product/import/csv/processor/price/listtypes |
68 | 68 | * @see controller/common/product/import/csv/processor/text/listtypes |
69 | 69 | */ |
70 | - $this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/attribute/listtypes'); |
|
70 | + $this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/attribute/listtypes'); |
|
71 | 71 | |
72 | - $this->cache = $this->getCache( 'attribute' ); |
|
72 | + $this->cache = $this->getCache('attribute'); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | * @param array $data List of CSV fields with position as key and data as value |
81 | 81 | * @return array List of data which hasn't been imported |
82 | 82 | */ |
83 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
83 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
84 | 84 | { |
85 | 85 | $context = $this->getContext(); |
86 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'attribute' ); |
|
87 | - $listManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' ); |
|
88 | - $separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" ); |
|
86 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'attribute'); |
|
87 | + $listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); |
|
88 | + $separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n"); |
|
89 | 89 | |
90 | 90 | $manager->begin(); |
91 | 91 | |
@@ -93,25 +93,25 @@ discard block |
||
93 | 93 | { |
94 | 94 | $pos = 0; |
95 | 95 | $delete = $attrcodes = array(); |
96 | - $map = $this->getMappedChunk( $data ); |
|
97 | - $listItems = $product->getListItems( 'attribute', $this->listTypes ); |
|
96 | + $map = $this->getMappedChunk($data); |
|
97 | + $listItems = $product->getListItems('attribute', $this->listTypes); |
|
98 | 98 | |
99 | - foreach( $listItems as $listId => $listItem ) |
|
99 | + foreach ($listItems as $listId => $listItem) |
|
100 | 100 | { |
101 | - if( isset( $map[$pos] ) ) |
|
101 | + if (isset($map[$pos])) |
|
102 | 102 | { |
103 | - if( !isset( $map[$pos]['attribute.code'] ) || !isset( $map[$pos]['attribute.type'] ) ) |
|
103 | + if (!isset($map[$pos]['attribute.code']) || !isset($map[$pos]['attribute.type'])) |
|
104 | 104 | { |
105 | - unset( $map[$pos] ); |
|
105 | + unset($map[$pos]); |
|
106 | 106 | continue; |
107 | 107 | } |
108 | 108 | |
109 | 109 | $refItem = $listItem->getRefItem(); |
110 | 110 | |
111 | - if( $refItem !== null && $map[$pos]['attribute.code'] === $refItem->getCode() |
|
111 | + if ($refItem !== null && $map[$pos]['attribute.code'] === $refItem->getCode() |
|
112 | 112 | && $map[$pos]['attribute.type'] === $refItem->getType() |
113 | - && ( !isset( $map[$pos]['product.lists.type'] ) || isset( $map[$pos]['product.lists.type'] ) |
|
114 | - && $map[$pos]['product.lists.type'] === $listItem->getType() ) |
|
113 | + && (!isset($map[$pos]['product.lists.type']) || isset($map[$pos]['product.lists.type']) |
|
114 | + && $map[$pos]['product.lists.type'] === $listItem->getType()) |
|
115 | 115 | ) { |
116 | 116 | $pos++; |
117 | 117 | continue; |
@@ -123,46 +123,46 @@ discard block |
||
123 | 123 | $pos++; |
124 | 124 | } |
125 | 125 | |
126 | - $listManager->deleteItems( $delete ); |
|
126 | + $listManager->deleteItems($delete); |
|
127 | 127 | |
128 | - foreach( $map as $pos => $list ) |
|
128 | + foreach ($map as $pos => $list) |
|
129 | 129 | { |
130 | - if( !isset( $list['attribute.code'] ) || $list['attribute.code'] === '' || $list['attribute.type'] === '' |
|
131 | - || isset( $list['product.lists.type'] ) && $this->listTypes !== null |
|
132 | - && !in_array( $list['product.lists.type'], (array) $this->listTypes ) |
|
130 | + if (!isset($list['attribute.code']) || $list['attribute.code'] === '' || $list['attribute.type'] === '' |
|
131 | + || isset($list['product.lists.type']) && $this->listTypes !== null |
|
132 | + && !in_array($list['product.lists.type'], (array) $this->listTypes) |
|
133 | 133 | ) { |
134 | 134 | continue; |
135 | 135 | } |
136 | 136 | |
137 | - $codes = explode( $separator, $list['attribute.code'] ); |
|
137 | + $codes = explode($separator, $list['attribute.code']); |
|
138 | 138 | |
139 | - foreach( $codes as $code ) |
|
139 | + foreach ($codes as $code) |
|
140 | 140 | { |
141 | - $attrItem = $this->getAttributeItem( $code, $list['attribute.type'] ); |
|
142 | - $attrItem->fromArray( $list ); |
|
143 | - $attrItem->setCode( $code ); |
|
144 | - $manager->saveItem( $attrItem ); |
|
141 | + $attrItem = $this->getAttributeItem($code, $list['attribute.type']); |
|
142 | + $attrItem->fromArray($list); |
|
143 | + $attrItem->setCode($code); |
|
144 | + $manager->saveItem($attrItem); |
|
145 | 145 | |
146 | - if( ( $listItem = array_shift( $listItems ) ) === null ) { |
|
146 | + if (($listItem = array_shift($listItems)) === null) { |
|
147 | 147 | $listItem = $listManager->createItem(); |
148 | 148 | } |
149 | 149 | |
150 | - $typecode = ( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' ); |
|
151 | - $list['product.lists.typeid'] = $this->getTypeId( 'product/lists/type', 'attribute', $typecode ); |
|
150 | + $typecode = (isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default'); |
|
151 | + $list['product.lists.typeid'] = $this->getTypeId('product/lists/type', 'attribute', $typecode); |
|
152 | 152 | $list['product.lists.refid'] = $attrItem->getId(); |
153 | 153 | $list['product.lists.parentid'] = $product->getId(); |
154 | 154 | $list['product.lists.domain'] = 'attribute'; |
155 | 155 | |
156 | - $listItem->fromArray( $this->addListItemDefaults( $list, $pos ) ); |
|
157 | - $listManager->saveItem( $listItem ); |
|
156 | + $listItem->fromArray($this->addListItemDefaults($list, $pos)); |
|
157 | + $listManager->saveItem($listItem); |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
161 | - $remaining = $this->getObject()->process( $product, $data ); |
|
161 | + $remaining = $this->getObject()->process($product, $data); |
|
162 | 162 | |
163 | 163 | $manager->commit(); |
164 | 164 | } |
165 | - catch( \Exception $e ) |
|
165 | + catch (\Exception $e) |
|
166 | 166 | { |
167 | 167 | $manager->rollback(); |
168 | 168 | throw $e; |
@@ -179,21 +179,21 @@ discard block |
||
179 | 179 | * @param string $type Attribute type |
180 | 180 | * @return \Aimeos\MShop\Attribute\Item\Iface Attribute item object |
181 | 181 | */ |
182 | - protected function getAttributeItem( $code, $type ) |
|
182 | + protected function getAttributeItem($code, $type) |
|
183 | 183 | { |
184 | - if( ( $item = $this->cache->get( $code, $type ) ) === null ) |
|
184 | + if (($item = $this->cache->get($code, $type)) === null) |
|
185 | 185 | { |
186 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
186 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
187 | 187 | |
188 | 188 | $item = $manager->createItem(); |
189 | - $item->setTypeId( $this->getTypeId( 'attribute/type', 'product', $type ) ); |
|
190 | - $item->setCode( $code ); |
|
191 | - $item->setLabel( $type . ' ' . $code ); |
|
192 | - $item->setStatus( 1 ); |
|
189 | + $item->setTypeId($this->getTypeId('attribute/type', 'product', $type)); |
|
190 | + $item->setCode($code); |
|
191 | + $item->setLabel($type . ' ' . $code); |
|
192 | + $item->setStatus(1); |
|
193 | 193 | |
194 | - $manager->saveItem( $item ); |
|
194 | + $manager->saveItem($item); |
|
195 | 195 | |
196 | - $this->cache->set( $item ); |
|
196 | + $this->cache->set($item); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | return $item; |
@@ -161,8 +161,7 @@ |
||
161 | 161 | $remaining = $this->getObject()->process( $product, $data ); |
162 | 162 | |
163 | 163 | $manager->commit(); |
164 | - } |
|
165 | - catch( \Exception $e ) |
|
164 | + } catch( \Exception $e ) |
|
166 | 165 | { |
167 | 166 | $manager->rollback(); |
168 | 167 | throw $e; |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
27 | 27 | * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor Decorated processor |
28 | 28 | */ |
29 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
30 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor = null ); |
|
29 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
30 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor = null); |
|
31 | 31 | |
32 | 32 | |
33 | 33 | /** |
@@ -37,5 +37,5 @@ discard block |
||
37 | 37 | * @param array $data List of CSV fields with position as key and data as value |
38 | 38 | * @return array List of data which hasn't been imported |
39 | 39 | */ |
40 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ); |
|
40 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data); |
|
41 | 41 | } |
42 | 42 | \ No newline at end of file |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
44 | 44 | * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor |
45 | 45 | */ |
46 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
47 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null ) |
|
46 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
47 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null) |
|
48 | 48 | { |
49 | - parent::__construct( $context, $mapping, $object ); |
|
49 | + parent::__construct($context, $mapping, $object); |
|
50 | 50 | |
51 | 51 | /** controller/common/product/import/csv/processor/catalog/listtypes |
52 | 52 | * Names of the catalog list types that are updated or removed |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | * @see controller/common/product/import/csv/processor/product/listtypes |
68 | 68 | * @see controller/common/product/import/csv/processor/text/listtypes |
69 | 69 | */ |
70 | - $this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/catalog/listtypes' ); |
|
70 | + $this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/catalog/listtypes'); |
|
71 | 71 | |
72 | - $this->cache = $this->getCache( 'catalog' ); |
|
72 | + $this->cache = $this->getCache('catalog'); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | * @param array $data List of CSV fields with position as key and data as value |
81 | 81 | * @return array List of data which hasn't been imported |
82 | 82 | */ |
83 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
83 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
84 | 84 | { |
85 | 85 | $context = $this->getContext(); |
86 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'catalog' ); |
|
87 | - $listManager = \Aimeos\MShop\Factory::createManager( $context, 'catalog/lists' ); |
|
86 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'catalog'); |
|
87 | + $listManager = \Aimeos\MShop\Factory::createManager($context, 'catalog/lists'); |
|
88 | 88 | |
89 | 89 | /** controller/common/product/import/csv/separator |
90 | 90 | * Single separator character for multiple entries in one field of the import file |
@@ -104,54 +104,54 @@ discard block |
||
104 | 104 | * @category Developer |
105 | 105 | * @see controller/common/product/import/csv/domains |
106 | 106 | */ |
107 | - $separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" ); |
|
107 | + $separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n"); |
|
108 | 108 | |
109 | 109 | $manager->begin(); |
110 | 110 | |
111 | 111 | try |
112 | 112 | { |
113 | 113 | $prodid = $product->getId(); |
114 | - $map = $this->getMappedChunk( $data ); |
|
115 | - $listItems = $this->getListItemPool( $product, $map ); |
|
114 | + $map = $this->getMappedChunk($data); |
|
115 | + $listItems = $this->getListItemPool($product, $map); |
|
116 | 116 | |
117 | - foreach( $map as $pos => $list ) |
|
117 | + foreach ($map as $pos => $list) |
|
118 | 118 | { |
119 | - if( !isset( $list['catalog.code'] ) || $list['catalog.code'] === '' || isset( $list['catalog.lists.type'] ) |
|
120 | - && $this->listTypes !== null && !in_array( $list['catalog.lists.type'], (array) $this->listTypes ) |
|
119 | + if (!isset($list['catalog.code']) || $list['catalog.code'] === '' || isset($list['catalog.lists.type']) |
|
120 | + && $this->listTypes !== null && !in_array($list['catalog.lists.type'], (array) $this->listTypes) |
|
121 | 121 | ) { |
122 | 122 | continue; |
123 | 123 | } |
124 | 124 | |
125 | - $codes = explode( $separator, $list['catalog.code'] ); |
|
126 | - $type = ( isset( $list['catalog.lists.type'] ) ? $list['catalog.lists.type'] : 'default' ); |
|
125 | + $codes = explode($separator, $list['catalog.code']); |
|
126 | + $type = (isset($list['catalog.lists.type']) ? $list['catalog.lists.type'] : 'default'); |
|
127 | 127 | |
128 | - foreach( $codes as $code ) |
|
128 | + foreach ($codes as $code) |
|
129 | 129 | { |
130 | - if( ( $catid = $this->cache->get( $code ) ) === null ) |
|
130 | + if (($catid = $this->cache->get($code)) === null) |
|
131 | 131 | { |
132 | 132 | $msg = 'No category for code "%1$s" available when importing product with code "%2$s"'; |
133 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( $msg, $code, $product->getCode() ) ); |
|
133 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf($msg, $code, $product->getCode())); |
|
134 | 134 | } |
135 | 135 | |
136 | - if( ( $listItem = array_shift( $listItems ) ) === null ) { |
|
136 | + if (($listItem = array_shift($listItems)) === null) { |
|
137 | 137 | $listItem = $listManager->createItem(); |
138 | 138 | } |
139 | 139 | |
140 | - $list['catalog.lists.typeid'] = $this->getTypeId( 'catalog/lists/type', 'product', $type ); |
|
140 | + $list['catalog.lists.typeid'] = $this->getTypeId('catalog/lists/type', 'product', $type); |
|
141 | 141 | $list['catalog.lists.parentid'] = $catid; |
142 | 142 | $list['catalog.lists.refid'] = $prodid; |
143 | 143 | $list['catalog.lists.domain'] = 'product'; |
144 | 144 | |
145 | - $listItem->fromArray( $this->addListItemDefaults( $list, $pos++ ) ); |
|
146 | - $listManager->saveItem( $listItem ); |
|
145 | + $listItem->fromArray($this->addListItemDefaults($list, $pos++)); |
|
146 | + $listManager->saveItem($listItem); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | - $remaining = $this->getObject()->process( $product, $data ); |
|
150 | + $remaining = $this->getObject()->process($product, $data); |
|
151 | 151 | |
152 | 152 | $manager->commit(); |
153 | 153 | } |
154 | - catch( \Exception $e ) |
|
154 | + catch (\Exception $e) |
|
155 | 155 | { |
156 | 156 | $manager->rollback(); |
157 | 157 | throw $e; |
@@ -168,13 +168,13 @@ discard block |
||
168 | 168 | * @param integer $pos Computed position of the list item in the associated list of items |
169 | 169 | * @return array Given associative list enriched by default values if they were not already set |
170 | 170 | */ |
171 | - protected function addListItemDefaults( array $list, $pos ) |
|
171 | + protected function addListItemDefaults(array $list, $pos) |
|
172 | 172 | { |
173 | - if( !isset( $list['catalog.lists.position'] ) ) { |
|
173 | + if (!isset($list['catalog.lists.position'])) { |
|
174 | 174 | $list['catalog.lists.position'] = $pos; |
175 | 175 | } |
176 | 176 | |
177 | - if( !isset( $list['catalog.lists.status'] ) ) { |
|
177 | + if (!isset($list['catalog.lists.status'])) { |
|
178 | 178 | $list['catalog.lists.status'] = 1; |
179 | 179 | } |
180 | 180 | |
@@ -189,25 +189,25 @@ discard block |
||
189 | 189 | * @param array|null $types List of catalog list types |
190 | 190 | * @return array List of catalog list items |
191 | 191 | */ |
192 | - protected function getListItems( $prodid, $types ) |
|
192 | + protected function getListItems($prodid, $types) |
|
193 | 193 | { |
194 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' ); |
|
194 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists'); |
|
195 | 195 | $search = $manager->createSearch(); |
196 | 196 | |
197 | 197 | $expr = array( |
198 | - $search->compare( '==', 'catalog.lists.domain', 'product' ), |
|
199 | - $search->compare( '==', 'catalog.lists.refid', $prodid ), |
|
198 | + $search->compare('==', 'catalog.lists.domain', 'product'), |
|
199 | + $search->compare('==', 'catalog.lists.refid', $prodid), |
|
200 | 200 | ); |
201 | 201 | |
202 | - if( $types !== null ) { |
|
203 | - $expr[] = $search->compare( '==', 'catalog.lists.type.code', $types ); |
|
202 | + if ($types !== null) { |
|
203 | + $expr[] = $search->compare('==', 'catalog.lists.type.code', $types); |
|
204 | 204 | } |
205 | 205 | |
206 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
207 | - $search->setSortations( array( $search->sort( '+', 'catalog.lists.position' ) ) ); |
|
208 | - $search->setSlice( 0, 0x7FFFFFFF ); |
|
206 | + $search->setConditions($search->combine('&&', $expr)); |
|
207 | + $search->setSortations(array($search->sort('+', 'catalog.lists.position'))); |
|
208 | + $search->setSlice(0, 0x7FFFFFFF); |
|
209 | 209 | |
210 | - return $manager->searchItems( $search ); |
|
210 | + return $manager->searchItems($search); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
@@ -218,16 +218,16 @@ discard block |
||
218 | 218 | * @param array $map List of associative arrays containing the chunked properties |
219 | 219 | * @return array List of list items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
220 | 220 | */ |
221 | - protected function getListItemPool( \Aimeos\MShop\Product\Item\Iface $product, array $map ) |
|
221 | + protected function getListItemPool(\Aimeos\MShop\Product\Item\Iface $product, array $map) |
|
222 | 222 | { |
223 | 223 | $pos = 0; |
224 | 224 | $delete = array(); |
225 | - $listItems = $this->getListItems( $product->getId(), $this->listTypes ); |
|
225 | + $listItems = $this->getListItems($product->getId(), $this->listTypes); |
|
226 | 226 | |
227 | - foreach( $listItems as $listId => $listItem ) |
|
227 | + foreach ($listItems as $listId => $listItem) |
|
228 | 228 | { |
229 | - if( isset( $map[$pos] ) && ( !isset( $map[$pos]['catalog.code'] ) |
|
230 | - || $this->cache->get( $map[$pos]['catalog.code'] ) == $listItem->getParentId() ) |
|
229 | + if (isset($map[$pos]) && (!isset($map[$pos]['catalog.code']) |
|
230 | + || $this->cache->get($map[$pos]['catalog.code']) == $listItem->getParentId()) |
|
231 | 231 | ) { |
232 | 232 | $pos++; |
233 | 233 | continue; |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | $pos++; |
239 | 239 | } |
240 | 240 | |
241 | - $listManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' ); |
|
242 | - $listManager->deleteItems( $delete ); |
|
241 | + $listManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists'); |
|
242 | + $listManager->deleteItems($delete); |
|
243 | 243 | |
244 | 244 | return $listItems; |
245 | 245 | } |
@@ -150,8 +150,7 @@ |
||
150 | 150 | $remaining = $this->getObject()->process( $product, $data ); |
151 | 151 | |
152 | 152 | $manager->commit(); |
153 | - } |
|
154 | - catch( \Exception $e ) |
|
153 | + } catch( \Exception $e ) |
|
155 | 154 | { |
156 | 155 | $manager->rollback(); |
157 | 156 | throw $e; |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
43 | 43 | * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor |
44 | 44 | */ |
45 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
46 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null ) |
|
45 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
46 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null) |
|
47 | 47 | { |
48 | - parent::__construct( $context, $mapping, $object ); |
|
48 | + parent::__construct($context, $mapping, $object); |
|
49 | 49 | |
50 | 50 | /** controller/common/product/import/csv/processor/media/listtypes |
51 | 51 | * Names of the product list types for media that are updated or removed |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @see controller/common/product/import/csv/processor/price/listtypes |
67 | 67 | * @see controller/common/product/import/csv/processor/text/listtypes |
68 | 68 | */ |
69 | - $this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/media/listtypes' ); |
|
69 | + $this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/media/listtypes'); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | |
@@ -77,71 +77,71 @@ discard block |
||
77 | 77 | * @param array $data List of CSV fields with position as key and data as value |
78 | 78 | * @return array List of data which hasn't been imported |
79 | 79 | */ |
80 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
80 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
81 | 81 | { |
82 | 82 | $context = $this->getContext(); |
83 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'media' ); |
|
84 | - $listManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' ); |
|
85 | - $separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" ); |
|
83 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'media'); |
|
84 | + $listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); |
|
85 | + $separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n"); |
|
86 | 86 | |
87 | 87 | $manager->begin(); |
88 | 88 | |
89 | 89 | try |
90 | 90 | { |
91 | - $map = $this->getMappedChunk( $data ); |
|
92 | - $listItems = $product->getListItems( 'media' ); |
|
91 | + $map = $this->getMappedChunk($data); |
|
92 | + $listItems = $product->getListItems('media'); |
|
93 | 93 | |
94 | - foreach( $map as $pos => $list ) |
|
94 | + foreach ($map as $pos => $list) |
|
95 | 95 | { |
96 | - if( !isset( $list['media.url'] ) || $list['media.url'] === '' || isset( $list['product.lists.type'] ) |
|
97 | - && $this->listTypes !== null && !in_array( $list['product.lists.type'], (array) $this->listTypes ) |
|
96 | + if (!isset($list['media.url']) || $list['media.url'] === '' || isset($list['product.lists.type']) |
|
97 | + && $this->listTypes !== null && !in_array($list['product.lists.type'], (array) $this->listTypes) |
|
98 | 98 | ) { |
99 | 99 | continue; |
100 | 100 | } |
101 | 101 | |
102 | - $urls = explode( $separator, $list['media.url'] ); |
|
103 | - $type = ( isset( $list['media.type'] ) ? $list['media.type'] : 'default' ); |
|
104 | - $typecode = ( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' ); |
|
105 | - $langid = ( isset( $list['media.languageid'] ) && $list['media.languageid'] !== '' ? $list['media.languageid'] : null ); |
|
102 | + $urls = explode($separator, $list['media.url']); |
|
103 | + $type = (isset($list['media.type']) ? $list['media.type'] : 'default'); |
|
104 | + $typecode = (isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default'); |
|
105 | + $langid = (isset($list['media.languageid']) && $list['media.languageid'] !== '' ? $list['media.languageid'] : null); |
|
106 | 106 | |
107 | - foreach( $urls as $url ) |
|
107 | + foreach ($urls as $url) |
|
108 | 108 | { |
109 | - if( ( $listItem = array_shift( $listItems ) ) !== null ) { |
|
109 | + if (($listItem = array_shift($listItems)) !== null) { |
|
110 | 110 | $refItem = $listItem->getRefItem(); |
111 | 111 | } else { |
112 | 112 | $listItem = $listManager->createItem(); |
113 | 113 | $refItem = $manager->createItem(); |
114 | 114 | } |
115 | 115 | |
116 | - $list['media.typeid'] = $this->getTypeId( 'media/type', 'product', $type ); |
|
116 | + $list['media.typeid'] = $this->getTypeId('media/type', 'product', $type); |
|
117 | 117 | $list['media.languageid'] = $langid; |
118 | 118 | $list['media.domain'] = 'product'; |
119 | 119 | $list['media.url'] = $url; |
120 | 120 | |
121 | - $refItem->fromArray( $this->addItemDefaults( $list ) ); |
|
122 | - $manager->saveItem( $refItem ); |
|
121 | + $refItem->fromArray($this->addItemDefaults($list)); |
|
122 | + $manager->saveItem($refItem); |
|
123 | 123 | |
124 | - $list['product.lists.typeid'] = $this->getTypeId( 'product/lists/type', 'media', $typecode ); |
|
124 | + $list['product.lists.typeid'] = $this->getTypeId('product/lists/type', 'media', $typecode); |
|
125 | 125 | $list['product.lists.parentid'] = $product->getId(); |
126 | 126 | $list['product.lists.refid'] = $refItem->getId(); |
127 | 127 | $list['product.lists.domain'] = 'media'; |
128 | 128 | |
129 | - $listItem->fromArray( $this->addListItemDefaults( $list, $pos++ ) ); |
|
130 | - $listManager->saveItem( $listItem ); |
|
129 | + $listItem->fromArray($this->addListItemDefaults($list, $pos++)); |
|
130 | + $listManager->saveItem($listItem); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
134 | - foreach( $listItems as $listItem ) |
|
134 | + foreach ($listItems as $listItem) |
|
135 | 135 | { |
136 | - $manager->deleteItem( $listItem->getRefItem()->getId() ); |
|
137 | - $listManager->deleteItem( $listItem->getId() ); |
|
136 | + $manager->deleteItem($listItem->getRefItem()->getId()); |
|
137 | + $listManager->deleteItem($listItem->getId()); |
|
138 | 138 | } |
139 | 139 | |
140 | - $remaining = $this->getObject()->process( $product, $data ); |
|
140 | + $remaining = $this->getObject()->process($product, $data); |
|
141 | 141 | |
142 | 142 | $manager->commit(); |
143 | 143 | } |
144 | - catch( \Exception $e ) |
|
144 | + catch (\Exception $e) |
|
145 | 145 | { |
146 | 146 | $manager->rollback(); |
147 | 147 | throw $e; |
@@ -157,17 +157,17 @@ discard block |
||
157 | 157 | * @param array $list Associative list of domain item keys and their values, e.g. "media.status" => 1 |
158 | 158 | * @return array Given associative list enriched by default values if they were not already set |
159 | 159 | */ |
160 | - protected function addItemDefaults( array $list ) |
|
160 | + protected function addItemDefaults(array $list) |
|
161 | 161 | { |
162 | - if( !isset( $list['media.label'] ) ) { |
|
162 | + if (!isset($list['media.label'])) { |
|
163 | 163 | $list['media.label'] = $list['media.url']; |
164 | 164 | } |
165 | 165 | |
166 | - if( !isset( $list['media.preview'] ) ) { |
|
166 | + if (!isset($list['media.preview'])) { |
|
167 | 167 | $list['media.preview'] = $list['media.url']; |
168 | 168 | } |
169 | 169 | |
170 | - if( !isset( $list['media.status'] ) ) { |
|
170 | + if (!isset($list['media.status'])) { |
|
171 | 171 | $list['media.status'] = 1; |
172 | 172 | } |
173 | 173 |
@@ -140,8 +140,7 @@ |
||
140 | 140 | $remaining = $this->getObject()->process( $product, $data ); |
141 | 141 | |
142 | 142 | $manager->commit(); |
143 | - } |
|
144 | - catch( \Exception $e ) |
|
143 | + } catch( \Exception $e ) |
|
145 | 144 | { |
146 | 145 | $manager->rollback(); |
147 | 146 | throw $e; |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
43 | 43 | * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor |
44 | 44 | */ |
45 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
46 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null ) |
|
45 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
46 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null) |
|
47 | 47 | { |
48 | - parent::__construct( $context, $mapping, $object ); |
|
48 | + parent::__construct($context, $mapping, $object); |
|
49 | 49 | |
50 | 50 | /** controller/common/product/import/csv/processor/price/listtypes |
51 | 51 | * Names of the product list types for prices that are updated or removed |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @see controller/common/product/import/csv/processor/product/listtypes |
67 | 67 | * @see controller/common/product/import/csv/processor/text/listtypes |
68 | 68 | */ |
69 | - $this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/price/listtypes' ); |
|
69 | + $this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/price/listtypes'); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | |
@@ -77,60 +77,60 @@ discard block |
||
77 | 77 | * @param array $data List of CSV fields with position as key and data as value |
78 | 78 | * @return array List of data which hasn't been imported |
79 | 79 | */ |
80 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
80 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
81 | 81 | { |
82 | - $listManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' ); |
|
83 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'price' ); |
|
82 | + $listManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists'); |
|
83 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'price'); |
|
84 | 84 | $manager->begin(); |
85 | 85 | |
86 | 86 | try |
87 | 87 | { |
88 | - $listItems = $product->getListItems( 'price' ); |
|
89 | - $map = $this->getMappedChunk( $data ); |
|
88 | + $listItems = $product->getListItems('price'); |
|
89 | + $map = $this->getMappedChunk($data); |
|
90 | 90 | |
91 | - foreach( $map as $pos => $list ) |
|
91 | + foreach ($map as $pos => $list) |
|
92 | 92 | { |
93 | - if( !isset( $list['price.value'] ) || $list['price.value'] === '' || isset( $list['product.lists.type'] ) |
|
94 | - && $this->listTypes !== null && !in_array( $list['product.lists.type'], (array) $this->listTypes ) |
|
93 | + if (!isset($list['price.value']) || $list['price.value'] === '' || isset($list['product.lists.type']) |
|
94 | + && $this->listTypes !== null && !in_array($list['product.lists.type'], (array) $this->listTypes) |
|
95 | 95 | ) { |
96 | 96 | continue; |
97 | 97 | } |
98 | 98 | |
99 | - if( ( $listItem = array_shift( $listItems ) ) !== null ) { |
|
99 | + if (($listItem = array_shift($listItems)) !== null) { |
|
100 | 100 | $refItem = $listItem->getRefItem(); |
101 | 101 | } else { |
102 | 102 | $listItem = $listManager->createItem(); |
103 | 103 | $refItem = $manager->createItem(); |
104 | 104 | } |
105 | 105 | |
106 | - $typecode = ( isset( $list['price.type'] ) ? $list['price.type'] : 'default' ); |
|
107 | - $list['price.typeid'] = $this->getTypeId( 'price/type', 'product', $typecode ); |
|
106 | + $typecode = (isset($list['price.type']) ? $list['price.type'] : 'default'); |
|
107 | + $list['price.typeid'] = $this->getTypeId('price/type', 'product', $typecode); |
|
108 | 108 | $list['price.domain'] = 'product'; |
109 | 109 | |
110 | - $refItem->fromArray( $this->addItemDefaults( $list ) ); |
|
111 | - $manager->saveItem( $refItem ); |
|
110 | + $refItem->fromArray($this->addItemDefaults($list)); |
|
111 | + $manager->saveItem($refItem); |
|
112 | 112 | |
113 | - $typecode = ( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' ); |
|
114 | - $list['product.lists.typeid'] = $this->getTypeId( 'product/lists/type', 'price', $typecode ); |
|
113 | + $typecode = (isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default'); |
|
114 | + $list['product.lists.typeid'] = $this->getTypeId('product/lists/type', 'price', $typecode); |
|
115 | 115 | $list['product.lists.parentid'] = $product->getId(); |
116 | 116 | $list['product.lists.refid'] = $refItem->getId(); |
117 | 117 | $list['product.lists.domain'] = 'price'; |
118 | 118 | |
119 | - $listItem->fromArray( $this->addListItemDefaults( $list, $pos ) ); |
|
120 | - $listManager->saveItem( $listItem ); |
|
119 | + $listItem->fromArray($this->addListItemDefaults($list, $pos)); |
|
120 | + $listManager->saveItem($listItem); |
|
121 | 121 | } |
122 | 122 | |
123 | - foreach( $listItems as $listItem ) |
|
123 | + foreach ($listItems as $listItem) |
|
124 | 124 | { |
125 | - $manager->deleteItem( $listItem->getRefItem()->getId() ); |
|
126 | - $listManager->deleteItem( $listItem->getId() ); |
|
125 | + $manager->deleteItem($listItem->getRefItem()->getId()); |
|
126 | + $listManager->deleteItem($listItem->getId()); |
|
127 | 127 | } |
128 | 128 | |
129 | - $remaining = $this->getObject()->process( $product, $data ); |
|
129 | + $remaining = $this->getObject()->process($product, $data); |
|
130 | 130 | |
131 | 131 | $manager->commit(); |
132 | 132 | } |
133 | - catch( \Exception $e ) |
|
133 | + catch (\Exception $e) |
|
134 | 134 | { |
135 | 135 | $manager->rollback(); |
136 | 136 | throw $e; |
@@ -146,17 +146,17 @@ discard block |
||
146 | 146 | * @param array $list Associative list of domain item keys and their values, e.g. "price.status" => 1 |
147 | 147 | * @return array Given associative list enriched by default values if they were not already set |
148 | 148 | */ |
149 | - protected function addItemDefaults( array $list ) |
|
149 | + protected function addItemDefaults(array $list) |
|
150 | 150 | { |
151 | - if( !isset( $list['price.currencyid'] ) ) { |
|
151 | + if (!isset($list['price.currencyid'])) { |
|
152 | 152 | $list['price.currencyid'] = $this->getContext()->getLocale()->getCurrencyId(); |
153 | 153 | } |
154 | 154 | |
155 | - if( !isset( $list['price.label'] ) ) { |
|
155 | + if (!isset($list['price.label'])) { |
|
156 | 156 | $list['price.label'] = $list['price.currencyid'] . ' ' . $list['price.value']; |
157 | 157 | } |
158 | 158 | |
159 | - if( !isset( $list['price.status'] ) ) { |
|
159 | + if (!isset($list['price.status'])) { |
|
160 | 160 | $list['price.status'] = 1; |
161 | 161 | } |
162 | 162 |
@@ -129,8 +129,7 @@ |
||
129 | 129 | $remaining = $this->getObject()->process( $product, $data ); |
130 | 130 | |
131 | 131 | $manager->commit(); |
132 | - } |
|
133 | - catch( \Exception $e ) |
|
132 | + } catch( \Exception $e ) |
|
134 | 133 | { |
135 | 134 | $manager->rollback(); |
136 | 135 | throw $e; |
@@ -40,32 +40,32 @@ discard block |
||
40 | 40 | * @param array $data List of CSV fields with position as key and data as value |
41 | 41 | * @return array List of data which hasn't been imported |
42 | 42 | */ |
43 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
43 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
44 | 44 | { |
45 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/property' ); |
|
45 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/property'); |
|
46 | 46 | $manager->begin(); |
47 | 47 | |
48 | 48 | try |
49 | 49 | { |
50 | 50 | $pos = 0; |
51 | 51 | $delete = array(); |
52 | - $map = $this->getMappedChunk( $data ); |
|
53 | - $items = $this->getPropertyItems( $product->getId() ); |
|
52 | + $map = $this->getMappedChunk($data); |
|
53 | + $items = $this->getPropertyItems($product->getId()); |
|
54 | 54 | |
55 | - foreach( $items as $id => $item ) |
|
55 | + foreach ($items as $id => $item) |
|
56 | 56 | { |
57 | - if( isset( $map[$pos] ) ) |
|
57 | + if (isset($map[$pos])) |
|
58 | 58 | { |
59 | - if( !isset( $map[$pos]['product.property.type'] ) || !isset( $map[$pos]['product.property.value'] ) ) |
|
59 | + if (!isset($map[$pos]['product.property.type']) || !isset($map[$pos]['product.property.value'])) |
|
60 | 60 | { |
61 | - unset( $map[$pos] ); |
|
61 | + unset($map[$pos]); |
|
62 | 62 | continue; |
63 | 63 | } |
64 | 64 | |
65 | - if( $map[$pos]['product.property.type'] === $item->getType() |
|
65 | + if ($map[$pos]['product.property.type'] === $item->getType() |
|
66 | 66 | && $map[$pos]['product.property.value'] === $item->getValue() |
67 | - && ( !isset( $map[$pos]['product.property.languageid'] ) |
|
68 | - || isset( $map[$pos]['product.property.languageid'] ) |
|
67 | + && (!isset($map[$pos]['product.property.languageid']) |
|
68 | + || isset($map[$pos]['product.property.languageid']) |
|
69 | 69 | && $map[$pos]['product.property.languageid'] === $item->getLanguageId() |
70 | 70 | ) |
71 | 71 | ) { |
@@ -79,31 +79,31 @@ discard block |
||
79 | 79 | $pos++; |
80 | 80 | } |
81 | 81 | |
82 | - $manager->deleteItems( $delete ); |
|
82 | + $manager->deleteItems($delete); |
|
83 | 83 | |
84 | - foreach( $map as $pos => $list ) |
|
84 | + foreach ($map as $pos => $list) |
|
85 | 85 | { |
86 | - if( $list['product.property.type'] == '' || $list['product.property.value'] == '' ) { |
|
86 | + if ($list['product.property.type'] == '' || $list['product.property.value'] == '') { |
|
87 | 87 | continue; |
88 | 88 | } |
89 | 89 | |
90 | 90 | $typecode = $list['product.property.type']; |
91 | - $list['product.property.typeid'] = $this->getTypeId( 'product/property/type', 'product', $typecode ); |
|
91 | + $list['product.property.typeid'] = $this->getTypeId('product/property/type', 'product', $typecode); |
|
92 | 92 | $list['product.property.parentid'] = $product->getId(); |
93 | 93 | |
94 | - if( ( $item = array_shift( $items ) ) === null ) { |
|
94 | + if (($item = array_shift($items)) === null) { |
|
95 | 95 | $item = $manager->createItem(); |
96 | 96 | } |
97 | 97 | |
98 | - $item->fromArray( $list ); |
|
99 | - $manager->saveItem( $item ); |
|
98 | + $item->fromArray($list); |
|
99 | + $manager->saveItem($item); |
|
100 | 100 | } |
101 | 101 | |
102 | - $remaining = $this->getObject()->process( $product, $data ); |
|
102 | + $remaining = $this->getObject()->process($product, $data); |
|
103 | 103 | |
104 | 104 | $manager->commit(); |
105 | 105 | } |
106 | - catch( \Exception $e ) |
|
106 | + catch (\Exception $e) |
|
107 | 107 | { |
108 | 108 | $manager->rollback(); |
109 | 109 | throw $e; |
@@ -119,13 +119,13 @@ discard block |
||
119 | 119 | * @param string $prodid Unique product ID |
120 | 120 | * @return array Associative list of product property items |
121 | 121 | */ |
122 | - protected function getPropertyItems( $prodid ) |
|
122 | + protected function getPropertyItems($prodid) |
|
123 | 123 | { |
124 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/property' ); |
|
124 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/property'); |
|
125 | 125 | |
126 | 126 | $search = $manager->createSearch(); |
127 | - $search->setConditions( $search->compare( '==', 'product.property.parentid', $prodid ) ); |
|
127 | + $search->setConditions($search->compare('==', 'product.property.parentid', $prodid)); |
|
128 | 128 | |
129 | - return $manager->searchItems( $search ); |
|
129 | + return $manager->searchItems($search); |
|
130 | 130 | } |
131 | 131 | } |
@@ -102,8 +102,7 @@ |
||
102 | 102 | $remaining = $this->getObject()->process( $product, $data ); |
103 | 103 | |
104 | 104 | $manager->commit(); |
105 | - } |
|
106 | - catch( \Exception $e ) |
|
105 | + } catch( \Exception $e ) |
|
107 | 106 | { |
108 | 107 | $manager->rollback(); |
109 | 108 | throw $e; |