@@ -461,13 +461,13 @@ discard block |
||
461 | 461 | */ |
462 | 462 | protected function addProducts( \Aimeos\MW\View\Iface $view ) |
463 | 463 | { |
464 | - $attrId = \Aimeos\MShop::create( $this->getContext(), 'attribute' )->find( 'custom', [], 'product', 'upload' )->getId(); |
|
464 | + $attrId = \Aimeos\MShop::create( $this->getContext(), 'attribute' )->find( 'custom', [], 'product', 'upload' )->getId(); |
|
465 | 465 | |
466 | - $fs = $this->getContext()->fs( 'fs' ); |
|
466 | + $fs = $this->getContext()->fs( 'fs' ); |
|
467 | 467 | |
468 | - if( !$fs->has('basket-upload' ) ) { |
|
469 | - $fs->mkdir( 'basket-upload' ); |
|
470 | - } |
|
468 | + if( !$fs->has('basket-upload' ) ) { |
|
469 | + $fs->mkdir( 'basket-upload' ); |
|
470 | + } |
|
471 | 471 | |
472 | 472 | $context = $this->getContext(); |
473 | 473 | $domains = ['attribute', 'media', 'price', 'product', 'text', 'custom']; |
@@ -494,26 +494,26 @@ discard block |
||
494 | 494 | $entries = (array) $view->param( 'b_prod', [] ); |
495 | 495 | |
496 | 496 | for($i = 0; $i < count($entries); ++$i) { |
497 | - $paths = []; |
|
498 | - if (isset( $entries[$i]['attrcustid'][$attrId] ) && is_array($entries[$i]['attrcustid'][$attrId])) { |
|
499 | - /** @var UploadedFile $file */ |
|
500 | - foreach($entries[$i]['attrcustid'][$attrId] as $file) { |
|
501 | - $filepath = 'basket-upload/' . md5($file->getFilename() . microtime(true)) . '.' . $file->extension(); |
|
502 | - try { |
|
503 | - $stream = fopen($file->getRealPath(), 'r+'); |
|
504 | - $fs->writes($filepath, $stream); |
|
505 | - fclose($stream); |
|
506 | - } catch (\Exception $ex) { |
|
507 | - Log::error($ex->getMessage()); |
|
508 | - } |
|
509 | - $paths[] = $filepath; |
|
510 | - } |
|
511 | - $entries[$i]['attrcustid'][$attrId] = $paths; |
|
512 | - } |
|
513 | - if( isset( $entries[$i]['prodid'] ) ) { |
|
514 | - $list[] = $entries[$i]['prodid']; |
|
515 | - } |
|
516 | - } |
|
497 | + $paths = []; |
|
498 | + if (isset( $entries[$i]['attrcustid'][$attrId] ) && is_array($entries[$i]['attrcustid'][$attrId])) { |
|
499 | + /** @var UploadedFile $file */ |
|
500 | + foreach($entries[$i]['attrcustid'][$attrId] as $file) { |
|
501 | + $filepath = 'basket-upload/' . md5($file->getFilename() . microtime(true)) . '.' . $file->extension(); |
|
502 | + try { |
|
503 | + $stream = fopen($file->getRealPath(), 'r+'); |
|
504 | + $fs->writes($filepath, $stream); |
|
505 | + fclose($stream); |
|
506 | + } catch (\Exception $ex) { |
|
507 | + Log::error($ex->getMessage()); |
|
508 | + } |
|
509 | + $paths[] = $filepath; |
|
510 | + } |
|
511 | + $entries[$i]['attrcustid'][$attrId] = $paths; |
|
512 | + } |
|
513 | + if( isset( $entries[$i]['prodid'] ) ) { |
|
514 | + $list[] = $entries[$i]['prodid']; |
|
515 | + } |
|
516 | + } |
|
517 | 517 | /*foreach( $entries as $values ) |
518 | 518 | { |
519 | 519 | if (isset( $values['attrcustid'][$attrId] )) { |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | |
536 | 536 | foreach( $entries as $values ) |
537 | 537 | { |
538 | - Log::debug(print_r($values, true)); |
|
538 | + Log::debug(print_r($values, true)); |
|
539 | 539 | if( ( $values['prodid'] ?? null ) && ( $values['quantity'] ?? 0 ) > 0 ) |
540 | 540 | { |
541 | 541 | $basketCntl->addProduct( $productCntl->get( $values['prodid'] ), |