9
9
use Magento \Catalog \Api \Data \ProductAttributeMediaGalleryEntryInterfaceFactory ;
10
10
use Magento \Catalog \Model \ProductRepository ;
11
11
use Magento \Framework \Exception \InputException ;
12
- use Magento \Framework \Exception \LocalizedException ;
13
12
use Magento \Framework \Exception \NoSuchEntityException ;
14
13
use Magento \Framework \Exception \StateException ;
15
- use Magento \Catalog \Api \Data \ProductInterface ;
16
-
17
14
18
15
/**
19
16
* Configurable product link management.
@@ -76,7 +73,7 @@ class LinkManagement implements \Magento\ConfigurableProduct\Api\LinkManagementI
76
73
* @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
77
74
* @param \Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory $attributeFactory
78
75
* @param \Magento\Catalog\Model\ProductRepository $mediaGalleryProcessor
79
- * @param \Magento\Catalog\Api\Data\ProductInterface $productInterface
76
+ * @param \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory $myModelFactory
80
77
*/
81
78
public function __construct (
82
79
\Magento \Catalog \Api \ProductRepositoryInterface $ productRepository ,
@@ -96,26 +93,11 @@ public function __construct(
96
93
$ this ->mediaGallery = $ mediaGalleryProcessor ?: \Magento \Framework \App \ObjectManager::getInstance ()
97
94
->get (\Magento \Catalog \Model \ProductRepository::class);
98
95
$ this ->myModelFactory = $ myModelFactory ?: \Magento \Framework \App \ObjectManager::getInstance ()
99
- ->get (\Magento \Catalog \Api \Data \ProductAttributeMediaGalleryEntryInterfaceFactory::class);;
96
+ ->get (\Magento \Catalog \Api \Data \ProductAttributeMediaGalleryEntryInterfaceFactory::class);
100
97
}
101
98
102
- /**
103
- * Process Media gallery data before save product.
104
- *
105
- * Compare Media Gallery Entries Data with existing Media Gallery
106
- * * If Media entry has not value_id set it as new
107
- * * If Existing entry 'value_id' absent in Media Gallery set 'removed' flag
108
- * * Merge Existing and new media gallery
109
- *
110
- * @param ProductInterface $product contains only existing media gallery items
111
- * @param array $mediaGalleryEntries array which contains all media gallery items
112
- * @throws InputException
113
- * @throws StateException
114
- * @throws LocalizedException
115
- */
116
99
/**
117
100
* @inheritdoc
118
- * @throws LocalizedException
119
101
*/
120
102
public function getChildren ($ sku )
121
103
{
@@ -152,6 +134,13 @@ public function getChildren($sku)
152
134
}
153
135
return $ childrenList ;
154
136
}
137
+
138
+ /**
139
+ * Get media entries
140
+ *
141
+ * @param array $images
142
+ * @return array
143
+ */
155
144
public function getMediaEntries ($ images )
156
145
{
157
146
$ media = $ this ->myModelFactory ->create ();
@@ -161,8 +150,8 @@ public function getMediaEntries($images)
161
150
$ media ->setMediaType ($ image ["media_type " ]);
162
151
$ media ->setLabel ($ image ["label " ]);
163
152
$ media ->setPosition ($ image ["position " ]);
164
- $ media ->setDisabled ($ image ["disabled " ]);
165
- $ media ->setFile ($ image ["file " ]);
153
+ $ media ->setDisabled ($ image ["disabled " ]);
154
+ $ media ->setFile ($ image ["file " ]);
166
155
$ mediaGalleryEntries []=$ media ->getData ();
167
156
}
168
157
return $ mediaGalleryEntries ;
@@ -258,10 +247,12 @@ public function removeChild($sku, $childSku)
258
247
* @return \Magento\ConfigurableProduct\Helper\Product\Options\Factory
259
248
*
260
249
* @deprecated 100.2.0
250
+ * @see Nothing
261
251
*/
262
252
private function getOptionsFactory ()
263
253
{
264
254
if (!$ this ->optionsFactory ) {
255
+ // phpcs:ignore Magento2.PHP.AutogeneratedClassNotInConstructor
265
256
$ this ->optionsFactory = \Magento \Framework \App \ObjectManager::getInstance ()
266
257
->get (\Magento \ConfigurableProduct \Helper \Product \Options \Factory::class);
267
258
}
0 commit comments