Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
joshine
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
joshine
Commits
cc735d1d
Commit
cc735d1d
authored
Dec 08, 2022
by
lmf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
断点
parent
05106c46
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
20 deletions
+22
-20
app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php
+22
-20
No files found.
app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php
View file @
cc735d1d
...
...
@@ -100,7 +100,7 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
$existingMediaGalleryEntries
=
$product
->
getMediaGalleryEntries
();
if
(
$existingMediaGalleryEntries
==
null
)
{
throw
new
NoSuchEntityException
(
__
(
'No image with the provided ID was found. Verify the ID and try again
11111111111
.'
)
__
(
'No image with the provided ID was found. Verify the ID and try again.'
)
);
}
$found
=
false
;
...
...
@@ -108,25 +108,27 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
foreach
(
$existingMediaGalleryEntries
as
$key
=>
$existingEntry
)
{
$existingEntryTypes
=
(
array
)
$existingEntry
->
getTypes
();
$existingEntry
->
setTypes
(
array_diff
(
$existingEntryTypes
,
$entryTypes
));
if
(
$existingEntry
->
getId
()
==
$entry
->
getId
())
{
$found
=
true
;
$existingMediaGalleryEntries
[
$key
]
=
$entry
;
}
}
if
(
!
$found
)
{
throw
new
NoSuchEntityException
(
__
(
'No image with the provided ID was found. Verify the ID and try again 22222222222.'
)
);
}
$product
->
setMediaGalleryEntries
(
$existingMediaGalleryEntries
);
try
{
$this
->
productRepository
->
save
(
$product
);
}
catch
(
\Exception
$exception
)
{
throw
new
StateException
(
__
(
"The product can't be saved."
));
}
return
true
;
$this
->
remove
(
$sku
,
$entry
->
getId
());
// if ($existingEntry->getId() == $entry->getId()) {
// $found = true;
// $existingMediaGalleryEntries[$key] = $entry;
// }
}
return
$this
->
create
(
$sku
,
$entry
);
// if (!$found) {
// throw new NoSuchEntityException(
// __('No image with the provided ID was found. Verify the ID and try again.')
// );
// }
// $product->setMediaGalleryEntries($existingMediaGalleryEntries);
//
// try {
// $this->productRepository->save($product);
// } catch (\Exception $exception) {
// throw new StateException(__("The product can't be saved."));
// }
// return true;
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment