-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NEW] upload media to order #153
Open
WLsupport
wants to merge
5
commits into
aimeos:master
Choose a base branch
from
WLsupport:features/upload_images_to_order
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
10ef3c2
client side for order media upload
WLsupport 9a6cc58
Merge remote-tracking branch 'origin/master' into features/upload_ima…
WLsupport ff76dcf
NEW: upload visual
WLsupport 4ae7dba
NEW: added type "file" for uploads as well
WLsupport e20f3a1
added file list to upload attribute
WLsupport File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -461,7 +461,9 @@ protected function addCoupon( \Aimeos\MW\View\Iface $view ) | |
*/ | ||
protected function addProducts( \Aimeos\MW\View\Iface $view ) | ||
{ | ||
$attrId = \Aimeos\MShop::create( $this->getContext(), 'attribute' )->find( 'custom', [], 'product', 'upload' )->getId(); | ||
$attrIds[] = \Aimeos\MShop::create( $this->getContext(), 'attribute' )->find( 'custom', [], 'product', 'upload' )->getId(); | ||
|
||
$attrIds[] = \Aimeos\MShop::create( $this->getContext(), 'attribute' )->find( 'file', [], 'product', 'upload' )->getId(); | ||
|
||
$fs = $this->getContext()->fs( 'fs' ); | ||
|
||
|
@@ -495,47 +497,30 @@ protected function addProducts( \Aimeos\MW\View\Iface $view ) | |
|
||
for($i = 0; $i < count($entries); ++$i) { | ||
$paths = []; | ||
if (isset( $entries[$i]['attrcustid'][$attrId] ) && is_array($entries[$i]['attrcustid'][$attrId])) { | ||
/** @var UploadedFile $file */ | ||
foreach($entries[$i]['attrcustid'][$attrId] as $file) { | ||
$filepath = 'basket-upload/' . md5($file->getFilename() . microtime(true)) . '.' . $file->extension(); | ||
try { | ||
$stream = fopen($file->getRealPath(), 'r+'); | ||
$fs->writes($filepath, $stream); | ||
fclose($stream); | ||
} catch (\Exception $ex) { | ||
Log::error($ex->getMessage()); | ||
} | ||
$paths[] = $filepath; | ||
} | ||
$entries[$i]['attrcustid'][$attrId] = $paths; | ||
} | ||
if( isset( $entries[$i]['prodid'] ) ) { | ||
$list[] = $entries[$i]['prodid']; | ||
} | ||
} | ||
/*foreach( $entries as $values ) | ||
{ | ||
if (isset( $values['attrcustid'][$attrId] )) { | ||
$file = $values['attrcustid'][$attrId]; | ||
$filepath = 'basket/' . md5($file->getFilename() . microtime(true)) . '.' . $file->extension(); | ||
try { | ||
$stream = fopen($file->getRealPath(), 'r+'); | ||
$fs->writes($filepath, $stream); | ||
fclose($stream); | ||
} catch (\Exception $ex) { | ||
Log::error($ex->getMessage()); | ||
} | ||
$values['attrcustid'][$attrId] = $filepath; | ||
} | ||
if( isset( $values['prodid'] ) ) { | ||
$list[] = $values['prodid']; | ||
foreach ($attrIds as $attrId) { | ||
if (isset($entries[$i]['attrcustid'][$attrId]) && is_array($entries[$i]['attrcustid'][$attrId])) { | ||
/** @var UploadedFile $file */ | ||
foreach ($entries[$i]['attrcustid'][$attrId] as $file) { | ||
$filepath = 'basket-upload/' . md5($file->getFilename() . microtime(true)) . '.' . $file->extension(); | ||
try { | ||
$stream = fopen($file->getRealPath(), 'r+'); | ||
$fs->writes($filepath, $stream); | ||
fclose($stream); | ||
} catch (\Exception $ex) { | ||
Log::error($ex->getMessage()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
$paths[] = $filepath; | ||
} | ||
$entries[$i]['attrcustid'][$attrId] = $paths; | ||
} | ||
if (isset($entries[$i]['prodid'])) { | ||
$list[] = $entries[$i]['prodid']; | ||
} | ||
} | ||
}*/ | ||
} | ||
|
||
foreach( $entries as $values ) | ||
{ | ||
Log::debug(print_r($values, true)); | ||
if( ( $values['prodid'] ?? null ) && ( $values['quantity'] ?? 0 ) > 0 ) | ||
{ | ||
$basketCntl->addProduct( $productCntl->get( $values['prodid'] ), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check return value of
fopen()