1 | <?php |
||
36 | class MediaGalleryObserver extends AbstractProductImportObserver |
||
37 | { |
||
38 | |||
39 | /** |
||
40 | * The media gallery attribute code. |
||
41 | * |
||
42 | * @var string |
||
43 | */ |
||
44 | const ATTRIBUTE_CODE = 'media_gallery'; |
||
45 | |||
46 | /** |
||
47 | * The ID of the parent product the media is related to. |
||
48 | * |
||
49 | * @var integer |
||
50 | */ |
||
51 | protected $parentId; |
||
52 | |||
53 | /** |
||
54 | * The ID of the persisted media gallery entity. |
||
55 | * |
||
56 | * @var integer |
||
57 | */ |
||
58 | protected $valueId; |
||
59 | |||
60 | /** |
||
61 | * Process the observer's business logic. |
||
62 | * |
||
63 | * @return array The processed row |
||
64 | */ |
||
65 | protected function process() |
||
96 | |||
97 | /** |
||
98 | * Prepare the product media gallery that has to be persisted. |
||
99 | * |
||
100 | * @return array The prepared product media gallery attributes |
||
101 | */ |
||
102 | protected function prepareProductMediaGalleryAttributes() |
||
124 | |||
125 | /** |
||
126 | * Prepare the product media gallery value to entity that has to be persisted. |
||
127 | * |
||
128 | * @return array The prepared product media gallery value to entity attributes |
||
129 | */ |
||
130 | protected function prepareProductMediaGalleryValueToEntityAttributes() |
||
141 | |||
142 | /** |
||
143 | * Initialize the product media gallery with the passed attributes and returns an instance. |
||
144 | * |
||
145 | * @param array $attr The product media gallery attributes |
||
146 | * |
||
147 | * @return array The initialized product media gallery |
||
148 | */ |
||
149 | protected function initializeProductMediaGallery(array $attr) |
||
153 | |||
154 | /** |
||
155 | * Initialize the product media gallery value to entity with the passed attributes and returns an instance. |
||
156 | * |
||
157 | * @param array $attr The product media gallery value to entity attributes |
||
158 | * |
||
159 | * @return array|null The initialized product media gallery value to entity, or NULL if the product media gallery value to entity already exists |
||
160 | */ |
||
161 | protected function initializeProductMediaGalleryValueToEntity(array $attr) |
||
165 | |||
166 | /** |
||
167 | * Map's the passed SKU of the parent product to it's PK. |
||
168 | * |
||
169 | * @param string $parentSku The SKU of the parent product |
||
170 | * |
||
171 | * @return integer The primary key used to create relations |
||
172 | */ |
||
173 | protected function mapParentSku($parentSku) |
||
177 | |||
178 | /** |
||
179 | * Return's the name of the created image. |
||
180 | * |
||
181 | * @return string The name of the created image |
||
182 | */ |
||
183 | protected function getParentImage() |
||
187 | |||
188 | /** |
||
189 | * Return's TRUE if the passed image is the parent one. |
||
190 | * |
||
191 | * @param string $image The imageD to check |
||
192 | * |
||
193 | * @return boolean TRUE if the passed image is the parent one |
||
194 | */ |
||
195 | protected function isParentImage($image) |
||
199 | |||
200 | /** |
||
201 | * Set's the value ID of the created media gallery entry. |
||
202 | * |
||
203 | * @param integer $parentValueId The ID of the created media gallery entry |
||
204 | * |
||
205 | * @return void |
||
206 | */ |
||
207 | protected function setParentValueId($parentValueId) |
||
211 | |||
212 | /** |
||
213 | * Return the entity ID for the passed SKU. |
||
214 | * |
||
215 | * @param string $sku The SKU to return the entity ID for |
||
216 | * |
||
217 | * @return integer The mapped entity ID |
||
218 | * @throws \Exception Is thrown if the SKU is not mapped yet |
||
219 | */ |
||
220 | protected function mapSkuToEntityId($sku) |
||
224 | |||
225 | /** |
||
226 | * Set's the ID of the parent product to relate the variant with. |
||
227 | * |
||
228 | * @param integer $parentId The ID of the parent product |
||
229 | * |
||
230 | * @return void |
||
231 | */ |
||
232 | protected function setParentId($parentId) |
||
236 | |||
237 | /** |
||
238 | * Reset the position counter to 1. |
||
239 | * |
||
240 | * @return void |
||
241 | */ |
||
242 | protected function resetPositionCounter() |
||
246 | |||
247 | /** |
||
248 | * Return's the EAV attribute with the passed attribute code. |
||
249 | * |
||
250 | * @param string $attributeCode The attribute code |
||
251 | * |
||
252 | * @return array The array with the EAV attribute |
||
253 | * @throws \Exception Is thrown if the attribute with the passed code is not available |
||
254 | */ |
||
255 | protected function getEavAttributeByAttributeCode($attributeCode) |
||
259 | |||
260 | /** |
||
261 | * Persist's the passed product media gallery data and return's the ID. |
||
262 | * |
||
263 | * @param array $productMediaGallery The product media gallery data to persist |
||
264 | * |
||
265 | * @return string The ID of the persisted entity |
||
266 | */ |
||
267 | protected function persistProductMediaGallery($productMediaGallery) |
||
271 | |||
272 | /** |
||
273 | * Persist's the passed product media gallery value to entity data. |
||
274 | * |
||
275 | * @param array $productMediaGalleryValueToEntity The product media gallery value to entity data to persist |
||
276 | * |
||
277 | * @return void |
||
278 | */ |
||
279 | protected function persistProductMediaGalleryValueToEntity($productMediaGalleryValueToEntity) |
||
283 | } |
||
284 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: