1
1
<?php
2
2
/**
3
- *
4
3
* Copyright © Magento, Inc. All rights reserved.
5
4
* See COPYING.txt for license details.
6
5
*/
7
6
8
7
namespace Magento \Catalog \Model \Product \Gallery ;
9
8
10
9
use Magento \Catalog \Api \Data \ProductAttributeMediaGalleryEntryInterface ;
11
- use Magento \Catalog \Api \Data \ProductInterface as Product ;
12
10
use Magento \Framework \Exception \InputException ;
13
11
use Magento \Framework \Exception \NoSuchEntityException ;
14
12
use Magento \Framework \Exception \StateException ;
15
13
use Magento \Framework \Api \ImageContentValidatorInterface ;
16
14
17
15
/**
16
+ * Class GalleryManagement
17
+ *
18
+ * Provides implementation of api interface ProductAttributeMediaGalleryManagementInterface
19
+ *
18
20
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
19
21
*/
20
22
class GalleryManagement implements \Magento \Catalog \Api \ProductAttributeMediaGalleryManagementInterface
@@ -44,7 +46,7 @@ public function __construct(
44
46
}
45
47
46
48
/**
47
- * { @inheritdoc}
49
+ * @inheritdoc
48
50
*/
49
51
public function create ($ sku , ProductAttributeMediaGalleryEntryInterface $ entry )
50
52
{
@@ -54,7 +56,7 @@ public function create($sku, ProductAttributeMediaGalleryEntryInterface $entry)
54
56
if (!$ this ->contentValidator ->isValid ($ entryContent )) {
55
57
throw new InputException (__ ('The image content is invalid. Verify the content and try again. ' ));
56
58
}
57
- $ product = $ this ->productRepository ->get ($ sku );
59
+ $ product = $ this ->productRepository ->get ($ sku, true );
58
60
59
61
$ existingMediaGalleryEntries = $ product ->getMediaGalleryEntries ();
60
62
$ existingEntryIds = [];
@@ -84,11 +86,11 @@ public function create($sku, ProductAttributeMediaGalleryEntryInterface $entry)
84
86
}
85
87
86
88
/**
87
- * { @inheritdoc}
89
+ * @inheritdoc
88
90
*/
89
91
public function update ($ sku , ProductAttributeMediaGalleryEntryInterface $ entry )
90
92
{
91
- $ product = $ this ->productRepository ->get ($ sku );
93
+ $ product = $ this ->productRepository ->get ($ sku, true );
92
94
$ existingMediaGalleryEntries = $ product ->getMediaGalleryEntries ();
93
95
if ($ existingMediaGalleryEntries == null ) {
94
96
throw new NoSuchEntityException (
@@ -125,11 +127,11 @@ public function update($sku, ProductAttributeMediaGalleryEntryInterface $entry)
125
127
}
126
128
127
129
/**
128
- * { @inheritdoc}
130
+ * @inheritdoc
129
131
*/
130
132
public function remove ($ sku , $ entryId )
131
133
{
132
- $ product = $ this ->productRepository ->get ($ sku );
134
+ $ product = $ this ->productRepository ->get ($ sku, true );
133
135
$ existingMediaGalleryEntries = $ product ->getMediaGalleryEntries ();
134
136
if ($ existingMediaGalleryEntries == null ) {
135
137
throw new NoSuchEntityException (
@@ -155,7 +157,7 @@ public function remove($sku, $entryId)
155
157
}
156
158
157
159
/**
158
- * { @inheritdoc}
160
+ * @inheritdoc
159
161
*/
160
162
public function get ($ sku , $ entryId )
161
163
{
@@ -176,7 +178,7 @@ public function get($sku, $entryId)
176
178
}
177
179
178
180
/**
179
- * { @inheritdoc}
181
+ * @inheritdoc
180
182
*/
181
183
public function getList ($ sku )
182
184
{
0 commit comments