1 | <?php |
||
37 | class MediaSubject extends AbstractProductSubject |
||
38 | { |
||
39 | |||
40 | /** |
||
41 | * The ID of the parent product to relate the variant with. |
||
42 | * |
||
43 | * @var integer |
||
44 | */ |
||
45 | protected $parentId; |
||
46 | |||
47 | /** |
||
48 | * The value ID of the created media gallery entry. |
||
49 | * |
||
50 | * @var integer |
||
51 | */ |
||
52 | protected $parentValueId; |
||
53 | |||
54 | /** |
||
55 | * The name of the craeted image. |
||
56 | * |
||
57 | * @var integer |
||
58 | */ |
||
59 | protected $parentImage; |
||
60 | |||
61 | /** |
||
62 | * The Magento installation directory. |
||
63 | * |
||
64 | * @var string |
||
65 | */ |
||
66 | protected $installationDir; |
||
67 | |||
68 | /** |
||
69 | * The directory with the Magento media files => target directory for images (relative to the root directory). |
||
70 | * |
||
71 | * @var string |
||
72 | */ |
||
73 | protected $mediaDir; |
||
74 | |||
75 | /** |
||
76 | * The directory with the images that have to be imported (relative to the root directory). |
||
77 | * |
||
78 | * @var string |
||
79 | */ |
||
80 | protected $imagesFileDir; |
||
81 | |||
82 | /** |
||
83 | * The position counter, if no position for the product media gallery value has been specified. |
||
84 | * |
||
85 | * @var integer |
||
86 | */ |
||
87 | protected $positionCounter = 1; |
||
88 | |||
89 | /** |
||
90 | * The available stores. |
||
91 | * |
||
92 | * @var array |
||
93 | */ |
||
94 | protected $stores = array(); |
||
95 | |||
96 | /** |
||
97 | * The mapping for the SKUs to the created entity IDs. |
||
98 | * |
||
99 | * @var array |
||
100 | */ |
||
101 | protected $skuEntityIdMapping = array(); |
||
102 | |||
103 | /** |
||
104 | * Intializes the previously loaded global data for exactly one variants. |
||
105 | * |
||
106 | * @return void |
||
107 | * @see \Importer\Csv\Actions\ProductImportAction::prepare() |
||
108 | */ |
||
109 | public function setUp() |
||
131 | |||
132 | /** |
||
133 | * Set's the Magento installation directory. |
||
134 | * |
||
135 | * @param string $installationDir The Magento installation directory |
||
136 | * |
||
137 | * @return void |
||
138 | */ |
||
139 | public function setInstallationDir($installationDir) |
||
143 | |||
144 | /** |
||
145 | * Return's the Magento installation directory. |
||
146 | * |
||
147 | * @return string The Magento installation directory |
||
148 | */ |
||
149 | public function getInstallationDir() |
||
153 | |||
154 | /** |
||
155 | * Set's directory with the Magento media files => target directory for images. |
||
156 | * |
||
157 | * @param string $mediaDir The directory with the Magento media files => target directory for images |
||
158 | * |
||
159 | * @return void |
||
160 | */ |
||
161 | public function setMediaDir($mediaDir) |
||
165 | |||
166 | /** |
||
167 | * Return's the directory with the Magento media files => target directory for images. |
||
168 | * |
||
169 | * @return string The directory with the Magento media files => target directory for images |
||
170 | */ |
||
171 | public function getMediaDir() |
||
175 | |||
176 | /** |
||
177 | * Set's directory with the images that have to be imported. |
||
178 | * |
||
179 | * @param string $imagesFileDir The directory with the images that have to be imported |
||
180 | * |
||
181 | * @return void |
||
182 | */ |
||
183 | public function setImagesFileDir($imagesFileDir) |
||
187 | |||
188 | /** |
||
189 | * Return's the directory with the images that have to be imported. |
||
190 | * |
||
191 | * @return string The directory with the images that have to be imported |
||
192 | */ |
||
193 | public function getImagesFileDir() |
||
197 | |||
198 | /** |
||
199 | * Set's the ID of the parent product to relate the variant with. |
||
200 | * |
||
201 | * @param integer $parentId The ID of the parent product |
||
202 | * |
||
203 | * @return void |
||
204 | */ |
||
205 | public function setParentId($parentId) |
||
209 | |||
210 | /** |
||
211 | * Return's the ID of the parent product to relate the variant with. |
||
212 | * |
||
213 | * @return integer The ID of the parent product |
||
214 | */ |
||
215 | public function getParentId() |
||
219 | |||
220 | /** |
||
221 | * Set's the value ID of the created media gallery entry. |
||
222 | * |
||
223 | * @param integer $parentValueId The ID of the created media gallery entry |
||
224 | * |
||
225 | * @return void |
||
226 | */ |
||
227 | public function setParentValueId($parentValueId) |
||
231 | |||
232 | /** |
||
233 | * Return's the value ID of the created media gallery entry. |
||
234 | * |
||
235 | * @return integer The ID of the created media gallery entry |
||
236 | */ |
||
237 | public function getParentValueId() |
||
241 | |||
242 | /** |
||
243 | * Set's the name of the created image. |
||
244 | * |
||
245 | * @param string $parentImage The name of the created image |
||
246 | * |
||
247 | * @return void |
||
248 | */ |
||
249 | public function setParentImage($parentImage) |
||
253 | |||
254 | /** |
||
255 | * Return's the name of the created image. |
||
256 | * |
||
257 | * @return string The name of the created image |
||
258 | */ |
||
259 | public function getParentImage() |
||
263 | |||
264 | /** |
||
265 | * Reset the position counter to 1. |
||
266 | * |
||
267 | * @return void |
||
268 | */ |
||
269 | public function resetPositionCounter() |
||
273 | |||
274 | /** |
||
275 | * Returns the acutal value of the position counter and raise's it by one. |
||
276 | * |
||
277 | * @return integer The actual value of the position counter |
||
278 | */ |
||
279 | public function raisePositionCounter() |
||
283 | |||
284 | /** |
||
285 | * Return the entity ID for the passed SKU. |
||
286 | * |
||
287 | * @param string $sku The SKU to return the entity ID for |
||
288 | * |
||
289 | * @return integer The mapped entity ID |
||
290 | * @throws \Exception Is thrown if the SKU is not mapped yet |
||
291 | */ |
||
292 | public function mapSkuToEntityId($sku) |
||
303 | |||
304 | /** |
||
305 | * Return's the store for the passed store code. |
||
306 | * |
||
307 | * @param string $storeCode The store code to return the store for |
||
308 | * |
||
309 | * @return array The requested store |
||
310 | * @throws \Exception Is thrown, if the requested store is not available |
||
311 | */ |
||
312 | public function getStoreByStoreCode($storeCode) |
||
323 | |||
324 | /** |
||
325 | * Upload's the file with the passed name to the Magento |
||
326 | * media directory. If the file already exists, the will |
||
327 | * be given a new name that will be returned. |
||
328 | * |
||
329 | * @param string $filename The name of the file to be uploaded |
||
330 | * |
||
331 | * @return string The name of the uploaded file |
||
332 | */ |
||
333 | public function uploadFile($filename) |
||
356 | |||
357 | /** |
||
358 | * Get new file name if the same is already exists. |
||
359 | * |
||
360 | * @param string $targetFilename The name of the exisising files |
||
361 | * |
||
362 | * @return string The new filename |
||
363 | */ |
||
364 | public function getNewFileName($targetFilename) |
||
393 | |||
394 | /** |
||
395 | * Persist's the passed product media gallery data and return's the ID. |
||
396 | * |
||
397 | * @param array $productMediaGallery The product media gallery data to persist |
||
398 | * |
||
399 | * @return string The ID of the persisted entity |
||
400 | */ |
||
401 | public function persistProductMediaGallery($productMediaGallery) |
||
405 | |||
406 | /** |
||
407 | * Persist's the passed product media gallery value data. |
||
408 | * |
||
409 | * @param array $productMediaGalleryValue The product media gallery value data to persist |
||
410 | * |
||
411 | * @return void |
||
412 | */ |
||
413 | public function persistProductMediaGalleryValue($productMediaGalleryValue) |
||
417 | |||
418 | /** |
||
419 | * Persist's the passed product media gallery value to entity data. |
||
420 | * |
||
421 | * @param array $productMediaGalleryValuetoEntity The product media gallery value to entity data to persist |
||
422 | * |
||
423 | * @return void |
||
424 | */ |
||
425 | public function persistProductMediaGalleryValueToEntity($productMediaGalleryValuetoEntity) |
||
429 | |||
430 | /** |
||
431 | * Persist's the passed product media gallery value video data. |
||
432 | * |
||
433 | * @param array $productMediaGalleryValueVideo The product media gallery value video data to persist |
||
434 | * |
||
435 | * @return void |
||
436 | */ |
||
437 | public function persistProductMediaGalleryValueVideo($productMediaGalleryValueVideo) |
||
441 | } |
||
442 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.