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
e2e35062
Commit
e2e35062
authored
Dec 08, 2022
by
lmf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
断点
parent
15b3dfaf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
10 deletions
+8
-10
app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php
+8
-10
No files found.
app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php
View file @
e2e35062
...
...
@@ -88,6 +88,8 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
return
$entry
->
getId
();
}
}
return
true
;
throw
new
StateException
(
__
(
'The new media gallery entry failed to save.'
));
}
...
...
@@ -100,7 +102,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.'
)
__
(
'No image with the provided ID was found. Verify the ID and try again
1
.'
)
);
}
$found
=
false
;
...
...
@@ -108,18 +110,15 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
foreach
(
$existingMediaGalleryEntries
as
$key
=>
$existingEntry
)
{
$existingEntryTypes
=
(
array
)
$existingEntry
->
getTypes
();
$existingEntry
->
setTypes
(
array_diff
(
$existingEntryTypes
,
$entryTypes
));
$this
->
remove
(
$sku
,
$entry
->
getId
());
// if ($existingEntry->getId() == $entry->getId()) {
// $found = true;
// $existingMediaGalleryEntries[$key] = $entry;
// }
unset
(
$existingMediaGalleryEntries
[
$key
]);
$found
=
true
;
break
;
}
if
(
!
$found
)
{
throw
new
NoSuchEntityException
(
__
(
'No image with the provided ID was found. Verify the ID and try again.'
)
__
(
'No image with the provided ID was found. Verify the ID and try again
2
.'
)
);
}
$product
->
setMediaGalleryEntries
(
$existingMediaGalleryEntries
);
...
...
@@ -130,9 +129,8 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
throw
new
StateException
(
__
(
"The product can't be saved."
));
}
return
$this
->
create
(
$sku
,
$entry
);
//
return true;
return
true
;
}
/**
...
...
@@ -144,7 +142,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.'
)
__
(
'No image with the provided ID was found. Verify the ID and try again
3
.'
)
);
}
$found
=
false
;
...
...
@@ -157,7 +155,7 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
}
if
(
!
$found
)
{
throw
new
NoSuchEntityException
(
__
(
'No image with the provided ID was found. Verify the ID and try again.'
)
__
(
'No image with the provided ID was found. Verify the ID and try again
4
.'
)
);
}
$product
->
setMediaGalleryEntries
(
$existingMediaGalleryEntries
);
...
...
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