1 | <?php |
||
36 | class ProductAttributeObserver extends AbstractProductImportObserver |
||
37 | { |
||
38 | |||
39 | /** |
||
40 | * The ID of the attribute to create the values for. |
||
41 | * |
||
42 | * @var integer |
||
43 | */ |
||
44 | protected $attributeId; |
||
45 | |||
46 | /** |
||
47 | * The attribute code of the attribute to create the values for. |
||
48 | * |
||
49 | * @var string |
||
50 | */ |
||
51 | protected $attributeCode; |
||
52 | |||
53 | /** |
||
54 | * The backend type of the attribute to create the values for. |
||
55 | * |
||
56 | * @var string |
||
57 | */ |
||
58 | protected $backendType; |
||
59 | |||
60 | /** |
||
61 | * The attribute value to process. |
||
62 | * |
||
63 | * @var mixed |
||
64 | */ |
||
65 | protected $attributeValue; |
||
66 | |||
67 | /** |
||
68 | * Will be invoked by the action on the events the listener has been registered for. |
||
69 | * |
||
70 | * @param array $row The row to handle |
||
71 | * |
||
72 | * @return array The modified row |
||
73 | * @see \TechDivision\Import\Product\Observers\ImportObserverInterface::handle() |
||
74 | */ |
||
75 | public function handle(array $row) |
||
87 | |||
88 | /** |
||
89 | * Process the observer's business logic. |
||
90 | * |
||
91 | * @return void |
||
92 | */ |
||
93 | public function process() |
||
155 | |||
156 | /** |
||
157 | * Prepare the attributes of the entity that has to be persisted. |
||
158 | * |
||
159 | * @return array The prepared attributes |
||
160 | */ |
||
161 | public function prepareAttributes() |
||
200 | |||
201 | /** |
||
202 | * Initialize the category product with the passed attributes and returns an instance. |
||
203 | * |
||
204 | * @param array $attr The category product attributes |
||
205 | * |
||
206 | * @return array The initialized category product |
||
207 | */ |
||
208 | public function initializeAttribute(array $attr) |
||
212 | |||
213 | /** |
||
214 | * Return's the PK to create the product => attribute relation. |
||
215 | * |
||
216 | * @return integer The PK to create the relation with |
||
217 | */ |
||
218 | public function getPrimaryKey() |
||
222 | |||
223 | /** |
||
224 | * Set's the attribute value to process. |
||
225 | * |
||
226 | * @param mixed $attributeValue The attribute value |
||
227 | * |
||
228 | * @return void |
||
229 | */ |
||
230 | public function setAttributeValue($attributeValue) |
||
234 | |||
235 | /** |
||
236 | * Return's the attribute value to process. |
||
237 | * |
||
238 | * @return mixed The attribute value |
||
239 | */ |
||
240 | public function getAttributeValue() |
||
244 | |||
245 | /** |
||
246 | * Set's the backend type of the attribute to create the values for. |
||
247 | * |
||
248 | * @param string $backendType The backend type |
||
249 | * |
||
250 | * @return void |
||
251 | */ |
||
252 | public function setBackendType($backendType) |
||
256 | |||
257 | /** |
||
258 | * Return's the backend type of the attribute to create the values for. |
||
259 | * |
||
260 | * @return string The backend type |
||
261 | */ |
||
262 | public function getBackendType() |
||
266 | |||
267 | /** |
||
268 | * Set's the attribute code of the attribute to create the values for. |
||
269 | * |
||
270 | * @param string $attributeCode The attribute code |
||
271 | * |
||
272 | * @return void |
||
273 | */ |
||
274 | public function setAttributeCode($attributeCode) |
||
278 | |||
279 | /** |
||
280 | * Return's the attribute code of the attribute to create the values for. |
||
281 | * |
||
282 | * @return string The attribute code |
||
283 | */ |
||
284 | public function getAttributeCode() |
||
288 | |||
289 | /** |
||
290 | * Set's the ID of the attribute to create the values for. |
||
291 | * |
||
292 | * @param integer $attributeId The attribute ID |
||
293 | * |
||
294 | * @return void |
||
295 | */ |
||
296 | public function setAttributeId($attributeId) |
||
300 | |||
301 | /** |
||
302 | * Return's the ID of the attribute to create the values for. |
||
303 | * |
||
304 | * @return integer The attribute ID |
||
305 | */ |
||
306 | public function getAttributeId() |
||
310 | |||
311 | /** |
||
312 | * Map the passed attribute code, if a header mapping exists and return the |
||
313 | * mapped mapping. |
||
314 | * |
||
315 | * @param string $attributeCode The attribute code to map |
||
316 | * |
||
317 | * @return string The mapped attribute code, or the original one |
||
318 | */ |
||
319 | public function mapAttributeCodeByHeaderMapping($attributeCode) |
||
323 | |||
324 | /** |
||
325 | * Return's the array with callbacks for the passed type. |
||
326 | * |
||
327 | * @param string $type The type of the callbacks to return |
||
328 | * |
||
329 | * @return array The callbacks |
||
330 | */ |
||
331 | public function getCallbacksByType($type) |
||
335 | |||
336 | /** |
||
337 | * Return's mapping for the supported backend types (for the product entity) => persist methods. |
||
338 | * |
||
339 | * @return array The mapping for the supported backend types |
||
340 | */ |
||
341 | public function getBackendTypes() |
||
345 | |||
346 | /** |
||
347 | * Return's the attributes for the attribute set of the product that has to be created. |
||
348 | * |
||
349 | * @return array The attributes |
||
350 | * @throws \Exception |
||
351 | */ |
||
352 | public function getAttributes() |
||
356 | |||
357 | /** |
||
358 | * Return's the store ID of the actual row, or of the default store |
||
359 | * if no store view code is set in the CSV file. |
||
360 | * |
||
361 | * @param string|null $default The default store view code to use, if no store view code is set in the CSV file |
||
362 | * |
||
363 | * @return integer The ID of the actual store |
||
364 | * @throws \Exception Is thrown, if the store with the actual code is not available |
||
365 | */ |
||
366 | public function getRowStoreId($default = null) |
||
370 | |||
371 | /** |
||
372 | * Persist's the passed product varchar attribute. |
||
373 | * |
||
374 | * @param array $attribute The attribute to persist |
||
375 | * |
||
376 | * @return void |
||
377 | */ |
||
378 | public function persistProductVarcharAttribute($attribute) |
||
382 | |||
383 | /** |
||
384 | * Persist's the passed product integer attribute. |
||
385 | * |
||
386 | * @param array $attribute The attribute to persist |
||
387 | * |
||
388 | * @return void |
||
389 | */ |
||
390 | public function persistProductIntAttribute($attribute) |
||
394 | |||
395 | /** |
||
396 | * Persist's the passed product decimal attribute. |
||
397 | * |
||
398 | * @param array $attribute The attribute to persist |
||
399 | * |
||
400 | * @return void |
||
401 | */ |
||
402 | public function persistProductDecimalAttribute($attribute) |
||
406 | |||
407 | /** |
||
408 | * Persist's the passed product datetime attribute. |
||
409 | * |
||
410 | * @param array $attribute The attribute to persist |
||
411 | * |
||
412 | * @return void |
||
413 | */ |
||
414 | public function persistProductDatetimeAttribute($attribute) |
||
418 | |||
419 | /** |
||
420 | * Persist's the passed product text attribute. |
||
421 | * |
||
422 | * @param array $attribute The attribute to persist |
||
423 | * |
||
424 | * @return void |
||
425 | */ |
||
426 | public function persistProductTextAttribute($attribute) |
||
430 | } |
||
431 |