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