1 | <?php |
||
36 | class MediaSubject extends AbstractProductSubject |
||
37 | { |
||
38 | |||
39 | /** |
||
40 | * The ID of the parent product to relate the variant with. |
||
41 | * |
||
42 | * @var integer |
||
43 | */ |
||
44 | protected $parentId; |
||
45 | |||
46 | /** |
||
47 | * The value ID of the created media gallery entry. |
||
48 | * |
||
49 | * @var integer |
||
50 | */ |
||
51 | protected $parentValueId; |
||
52 | |||
53 | /** |
||
54 | * The name of the craeted image. |
||
55 | * |
||
56 | * @var integer |
||
57 | */ |
||
58 | protected $parentImage; |
||
59 | |||
60 | /** |
||
61 | * The Magento installation directory. |
||
62 | * |
||
63 | * @var string |
||
64 | */ |
||
65 | protected $installationDir; |
||
66 | |||
67 | /** |
||
68 | * The directory with the Magento media files => target directory for images (relative to the root directory). |
||
69 | * |
||
70 | * @var string |
||
71 | */ |
||
72 | protected $mediaDir; |
||
73 | |||
74 | /** |
||
75 | * The directory with the images that have to be imported (relative to the root directory). |
||
76 | * |
||
77 | * @var string |
||
78 | */ |
||
79 | protected $imagesFileDir; |
||
80 | |||
81 | /** |
||
82 | * The position counter, if no position for the product media gallery value has been specified. |
||
83 | * |
||
84 | * @var integer |
||
85 | */ |
||
86 | protected $positionCounter = 1; |
||
87 | |||
88 | /** |
||
89 | * The available stores. |
||
90 | * |
||
91 | * @var array |
||
92 | */ |
||
93 | protected $stores = array(); |
||
94 | |||
95 | /** |
||
96 | * The mapping for the SKUs to the created entity IDs. |
||
97 | * |
||
98 | * @var array |
||
99 | */ |
||
100 | protected $skuEntityIdMapping = array(); |
||
101 | |||
102 | /** |
||
103 | * Intializes the previously loaded global data for exactly one variants. |
||
104 | * |
||
105 | * @return void |
||
106 | * @see \Importer\Csv\Actions\ProductImportAction::prepare() |
||
107 | */ |
||
108 | public function setUp() |
||
130 | |||
131 | /** |
||
132 | * Set's the Magento installation directory. |
||
133 | * |
||
134 | * @param string $installationDir The Magento installation directory |
||
135 | * |
||
136 | * @return void |
||
137 | */ |
||
138 | public function setInstallationDir($installationDir) |
||
142 | |||
143 | /** |
||
144 | * Return's the Magento installation directory. |
||
145 | * |
||
146 | * @return string The Magento installation directory |
||
147 | */ |
||
148 | public function getInstallationDir() |
||
152 | |||
153 | /** |
||
154 | * Set's directory with the Magento media files => target directory for images. |
||
155 | * |
||
156 | * @param string $mediaDir The directory with the Magento media files => target directory for images |
||
157 | * |
||
158 | * @return void |
||
159 | */ |
||
160 | public function setMediaDir($mediaDir) |
||
164 | |||
165 | /** |
||
166 | * Return's the directory with the Magento media files => target directory for images. |
||
167 | * |
||
168 | * @return string The directory with the Magento media files => target directory for images |
||
169 | */ |
||
170 | public function getMediaDir() |
||
174 | |||
175 | /** |
||
176 | * Set's directory with the images that have to be imported. |
||
177 | * |
||
178 | * @param string $imagesFileDir The directory with the images that have to be imported |
||
179 | * |
||
180 | * @return void |
||
181 | */ |
||
182 | public function setImagesFileDir($imagesFileDir) |
||
186 | |||
187 | /** |
||
188 | * Return's the directory with the images that have to be imported. |
||
189 | * |
||
190 | * @return string The directory with the images that have to be imported |
||
191 | */ |
||
192 | public function getImagesFileDir() |
||
196 | |||
197 | /** |
||
198 | * Set's the ID of the parent product to relate the variant with. |
||
199 | * |
||
200 | * @param integer $parentId The ID of the parent product |
||
201 | * |
||
202 | * @return void |
||
203 | */ |
||
204 | public function setParentId($parentId) |
||
208 | |||
209 | /** |
||
210 | * Return's the ID of the parent product to relate the variant with. |
||
211 | * |
||
212 | * @return integer The ID of the parent product |
||
213 | */ |
||
214 | public function getParentId() |
||
218 | |||
219 | /** |
||
220 | * Set's the value ID of the created media gallery entry. |
||
221 | * |
||
222 | * @param integer $parentValueId The ID of the created media gallery entry |
||
223 | * |
||
224 | * @return void |
||
225 | */ |
||
226 | public function setParentValueId($parentValueId) |
||
230 | |||
231 | /** |
||
232 | * Return's the value ID of the created media gallery entry. |
||
233 | * |
||
234 | * @return integer The ID of the created media gallery entry |
||
235 | */ |
||
236 | public function getParentValueId() |
||
240 | |||
241 | /** |
||
242 | * Set's the name of the created image. |
||
243 | * |
||
244 | * @param string $parentImage The name of the created image |
||
245 | * |
||
246 | * @return void |
||
247 | */ |
||
248 | public function setParentImage($parentImage) |
||
252 | |||
253 | /** |
||
254 | * Return's the name of the created image. |
||
255 | * |
||
256 | * @return string The name of the created image |
||
257 | */ |
||
258 | public function getParentImage() |
||
262 | |||
263 | /** |
||
264 | * Reset the position counter to 1. |
||
265 | * |
||
266 | * @return void |
||
267 | */ |
||
268 | public function resetPositionCounter() |
||
272 | |||
273 | /** |
||
274 | * Returns the acutal value of the position counter and raise's it by one. |
||
275 | * |
||
276 | * @return integer The actual value of the position counter |
||
277 | */ |
||
278 | public function raisePositionCounter() |
||
282 | |||
283 | /** |
||
284 | * Return the entity ID for the passed SKU. |
||
285 | * |
||
286 | * @param string $sku The SKU to return the entity ID for |
||
287 | * |
||
288 | * @return integer The mapped entity ID |
||
289 | * @throws \Exception Is thrown if the SKU is not mapped yet |
||
290 | */ |
||
291 | public function mapSkuToEntityId($sku) |
||
302 | |||
303 | /** |
||
304 | * Return's the store for the passed store code. |
||
305 | * |
||
306 | * @param string $storeCode The store code to return the store for |
||
307 | * |
||
308 | * @return array The requested store |
||
309 | * @throws \Exception Is thrown, if the requested store is not available |
||
310 | */ |
||
311 | public function getStoreByStoreCode($storeCode) |
||
322 | |||
323 | /** |
||
324 | * Upload's the file with the passed name to the Magento |
||
325 | * media directory. If the file already exists, the will |
||
326 | * be given a new name that will be returned. |
||
327 | * |
||
328 | * @param string $filename The name of the file to be uploaded |
||
329 | * |
||
330 | * @return string The name of the uploaded file |
||
331 | */ |
||
332 | public function uploadFile($filename) |
||
358 | |||
359 | /** |
||
360 | * Get new file name if the same is already exists. |
||
361 | * |
||
362 | * @param string $targetFilename The name of the exisising files |
||
363 | * |
||
364 | * @return string The new filename |
||
365 | */ |
||
366 | public function getNewFileName($targetFilename) |
||
395 | |||
396 | /** |
||
397 | * Load's the product media gallery with the passed attribute ID + value. |
||
398 | * |
||
399 | * @param integer $attributeId The attribute ID of the product media gallery to load |
||
400 | * @param string $value The value of the product media gallery to load |
||
401 | * |
||
402 | * @return array The product media gallery |
||
403 | */ |
||
404 | public function loadProductMediaGallery($attributeId, $value) |
||
408 | |||
409 | /** |
||
410 | * Load's the product media gallery with the passed value/entity ID. |
||
411 | * |
||
412 | * @param integer $valueId The value ID of the product media gallery value to entity to load |
||
413 | * @param integer $entityId The entity ID of the product media gallery value to entity to load |
||
414 | * |
||
415 | * @return array The product media gallery |
||
416 | */ |
||
417 | public function loadProductMediaGalleryValueToEntity($valueId, $entityId) |
||
421 | |||
422 | /** |
||
423 | * Load's the product media gallery value with the passed value/store/parent ID. |
||
424 | * |
||
425 | * @param integer $valueId The value ID of the product media gallery value to load |
||
426 | * @param string $storeId The store ID of the product media gallery value to load |
||
427 | * @param string $entityId The entity ID of the parent product of the product media gallery value to load |
||
428 | * |
||
429 | * @return array The product media gallery value |
||
430 | */ |
||
431 | public function loadProductMediaGalleryValue($valueId, $storeId, $entityId) |
||
435 | |||
436 | /** |
||
437 | * Persist's the passed product media gallery data and return's the ID. |
||
438 | * |
||
439 | * @param array $productMediaGallery The product media gallery data to persist |
||
440 | * |
||
441 | * @return string The ID of the persisted entity |
||
442 | */ |
||
443 | public function persistProductMediaGallery($productMediaGallery) |
||
447 | |||
448 | /** |
||
449 | * Persist's the passed product media gallery value data. |
||
450 | * |
||
451 | * @param array $productMediaGalleryValue The product media gallery value data to persist |
||
452 | * |
||
453 | * @return void |
||
454 | */ |
||
455 | public function persistProductMediaGalleryValue($productMediaGalleryValue) |
||
459 | |||
460 | /** |
||
461 | * Persist's the passed product media gallery value to entity data. |
||
462 | * |
||
463 | * @param array $productMediaGalleryValuetoEntity The product media gallery value to entity data to persist |
||
464 | * |
||
465 | * @return void |
||
466 | */ |
||
467 | public function persistProductMediaGalleryValueToEntity($productMediaGalleryValuetoEntity) |
||
471 | |||
472 | /** |
||
473 | * Persist's the passed product media gallery value video data. |
||
474 | * |
||
475 | * @param array $productMediaGalleryValueVideo The product media gallery value video data to persist |
||
476 | * |
||
477 | * @return void |
||
478 | */ |
||
479 | public function persistProductMediaGalleryValueVideo($productMediaGalleryValueVideo) |
||
483 | } |
||
484 |
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.