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
674ecee7
Commit
674ecee7
authored
Jul 13, 2023
by
liumengfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化批量上传图片接口
parent
36ac22d7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
14 deletions
+23
-14
app/code/Joshine/Catalog/Api/ProductAttributeMediaGalleryManagementInterface.php
+4
-6
app/code/Joshine/Catalog/Model/Product/Gallery/GalleryManagement.php
+19
-8
No files found.
app/code/Joshine/Catalog/Api/ProductAttributeMediaGalleryManagementInterface.php
View file @
674ecee7
...
...
@@ -21,7 +21,7 @@ interface ProductAttributeMediaGalleryManagementInterface
*
* @api
* @param mixed $entry
* @return
boolean
* @return
\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface[]
*/
public
function
add
(
$entry
...
...
@@ -44,12 +44,10 @@ interface ProductAttributeMediaGalleryManagementInterface
);
/**
*
Update gallery entry
*
Retrieve the list of gallery entries associated with given product
*
* @param string $sku
* @param \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface $entry
* @return bool
* @throws \Magento\Framework\Exception\NoSuchEntityException
* @throws \Magento\Framework\Exception\StateException
* @return \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface[]
*/
public
function
getList
(
$sku
);
}
app/code/Joshine/Catalog/Model/Product/Gallery/GalleryManagement.php
View file @
674ecee7
...
...
@@ -76,9 +76,9 @@ class GalleryManagement implements \Joshine\Catalog\Api\ProductAttributeMediaGal
if
(
empty
(
$content
))
{
return
0
;
}
$ids
=
[];
$ids
=
true
;
$sku
=
$content
[
0
][
'sku'
];
foreach
(
$content
as
$entry
){
$sku
=
$entry
[
'sku'
];
$this
->
entry
->
setMediaType
(
$entry
[
'media_type'
]);
$this
->
entry
->
setDisabled
(
$entry
[
'disabled'
]);
$this
->
entry
->
setFile
(
$entry
[
'file'
]);
...
...
@@ -92,18 +92,18 @@ class GalleryManagement implements \Joshine\Catalog\Api\ProductAttributeMediaGal
$imageContent
->
setType
(
$entry
[
'content'
][
'type'
]);
$this
->
entry
->
setContent
(
$imageContent
);
$id
=
$this
->
create
(
$sku
,
$this
->
entry
);
if
(
is_numeric
((
int
)
$id
)){
$ids
[
$sku
]
=
[
"id"
=>
(
int
)
$id
]
;
if
(
!
is_numeric
((
int
)
$id
)){
$ids
=
false
;
}
}
if
(
empty
(
$ids
)
){
if
(
!
$ids
){
throw
new
StateException
(
__
(
'Batch upload of product images failed'
));
}
return
$ids
;
return
$this
->
getList
(
$sku
);
}
/**
* @inheritdoc
*/
...
...
@@ -152,4 +152,15 @@ class GalleryManagement implements \Joshine\Catalog\Api\ProductAttributeMediaGal
throw
new
StateException
(
__
(
'The new media gallery entry failed to save.'
));
}
/**
* @inheritdoc
*/
public
function
getList
(
$sku
)
{
/** @var \Magento\Catalog\Model\Product $product */
$product
=
$this
->
productRepository
->
get
(
$sku
);
return
$product
->
getMediaGalleryEntries
();
}
}
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