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 | * Process the observer's business logic. |
||
69 | * |
||
70 | * @return void |
||
71 | */ |
||
72 | protected function process() |
||
134 | |||
135 | /** |
||
136 | * Prepare the attributes of the entity that has to be persisted. |
||
137 | * |
||
138 | * @return array The prepared attributes |
||
139 | */ |
||
140 | protected function prepareAttributes() |
||
179 | |||
180 | /** |
||
181 | * Initialize the category product with the passed attributes and returns an instance. |
||
182 | * |
||
183 | * @param array $attr The category product attributes |
||
184 | * |
||
185 | * @return array The initialized category product |
||
186 | */ |
||
187 | protected function initializeAttribute(array $attr) |
||
191 | |||
192 | /** |
||
193 | * Return's the PK to create the product => attribute relation. |
||
194 | * |
||
195 | * @return integer The PK to create the relation with |
||
196 | */ |
||
197 | protected function getPrimaryKey() |
||
201 | |||
202 | /** |
||
203 | * Set's the attribute value to process. |
||
204 | * |
||
205 | * @param mixed $attributeValue The attribute value |
||
206 | * |
||
207 | * @return void |
||
208 | */ |
||
209 | protected function setAttributeValue($attributeValue) |
||
213 | |||
214 | /** |
||
215 | * Return's the attribute value to process. |
||
216 | * |
||
217 | * @return mixed The attribute value |
||
218 | */ |
||
219 | protected function getAttributeValue() |
||
223 | |||
224 | /** |
||
225 | * Set's the backend type of the attribute to create the values for. |
||
226 | * |
||
227 | * @param string $backendType The backend type |
||
228 | * |
||
229 | * @return void |
||
230 | */ |
||
231 | protected function setBackendType($backendType) |
||
235 | |||
236 | /** |
||
237 | * Return's the backend type of the attribute to create the values for. |
||
238 | * |
||
239 | * @return string The backend type |
||
240 | */ |
||
241 | protected function getBackendType() |
||
245 | |||
246 | /** |
||
247 | * Set's the attribute code of the attribute to create the values for. |
||
248 | * |
||
249 | * @param string $attributeCode The attribute code |
||
250 | * |
||
251 | * @return void |
||
252 | */ |
||
253 | protected function setAttributeCode($attributeCode) |
||
257 | |||
258 | /** |
||
259 | * Return's the attribute code of the attribute to create the values for. |
||
260 | * |
||
261 | * @return string The attribute code |
||
262 | */ |
||
263 | protected function getAttributeCode() |
||
267 | |||
268 | /** |
||
269 | * Set's the ID of the attribute to create the values for. |
||
270 | * |
||
271 | * @param integer $attributeId The attribute ID |
||
272 | * |
||
273 | * @return void |
||
274 | */ |
||
275 | protected function setAttributeId($attributeId) |
||
279 | |||
280 | /** |
||
281 | * Return's the ID of the attribute to create the values for. |
||
282 | * |
||
283 | * @return integer The attribute ID |
||
284 | */ |
||
285 | protected function getAttributeId() |
||
289 | |||
290 | /** |
||
291 | * Map the passed attribute code, if a header mapping exists and return the |
||
292 | * mapped mapping. |
||
293 | * |
||
294 | * @param string $attributeCode The attribute code to map |
||
295 | * |
||
296 | * @return string The mapped attribute code, or the original one |
||
297 | */ |
||
298 | protected function mapAttributeCodeByHeaderMapping($attributeCode) |
||
302 | |||
303 | /** |
||
304 | * Return's the array with callbacks for the passed type. |
||
305 | * |
||
306 | * @param string $type The type of the callbacks to return |
||
307 | * |
||
308 | * @return array The callbacks |
||
309 | */ |
||
310 | protected function getCallbacksByType($type) |
||
314 | |||
315 | /** |
||
316 | * Return's mapping for the supported backend types (for the product entity) => persist methods. |
||
317 | * |
||
318 | * @return array The mapping for the supported backend types |
||
319 | */ |
||
320 | protected function getBackendTypes() |
||
324 | |||
325 | /** |
||
326 | * Return's the attributes for the attribute set of the product that has to be created. |
||
327 | * |
||
328 | * @return array The attributes |
||
329 | * @throws \Exception |
||
330 | */ |
||
331 | protected function getAttributes() |
||
335 | |||
336 | /** |
||
337 | * Return's the store ID of the actual row, or of the default store |
||
338 | * if no store view code is set in the CSV file. |
||
339 | * |
||
340 | * @param string|null $default The default store view code to use, if no store view code is set in the CSV file |
||
341 | * |
||
342 | * @return integer The ID of the actual store |
||
343 | * @throws \Exception Is thrown, if the store with the actual code is not available |
||
344 | */ |
||
345 | protected function getRowStoreId($default = null) |
||
349 | |||
350 | /** |
||
351 | * Persist's the passed product varchar attribute. |
||
352 | * |
||
353 | * @param array $attribute The attribute to persist |
||
354 | * |
||
355 | * @return void |
||
356 | */ |
||
357 | protected function persistProductVarcharAttribute($attribute) |
||
361 | |||
362 | /** |
||
363 | * Persist's the passed product integer attribute. |
||
364 | * |
||
365 | * @param array $attribute The attribute to persist |
||
366 | * |
||
367 | * @return void |
||
368 | */ |
||
369 | protected function persistProductIntAttribute($attribute) |
||
373 | |||
374 | /** |
||
375 | * Persist's the passed product decimal attribute. |
||
376 | * |
||
377 | * @param array $attribute The attribute to persist |
||
378 | * |
||
379 | * @return void |
||
380 | */ |
||
381 | protected function persistProductDecimalAttribute($attribute) |
||
385 | |||
386 | /** |
||
387 | * Persist's the passed product datetime attribute. |
||
388 | * |
||
389 | * @param array $attribute The attribute to persist |
||
390 | * |
||
391 | * @return void |
||
392 | */ |
||
393 | protected function persistProductDatetimeAttribute($attribute) |
||
397 | |||
398 | /** |
||
399 | * Persist's the passed product text attribute. |
||
400 | * |
||
401 | * @param array $attribute The attribute to persist |
||
402 | * |
||
403 | * @return void |
||
404 | */ |
||
405 | protected function persistProductTextAttribute($attribute) |
||
409 | } |
||
410 |