|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Attribute\Observers\AbstractAttributeExportObserver |
|
5
|
|
|
* |
|
6
|
|
|
* NOTICE OF LICENSE |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
|
9
|
|
|
* that is available through the world-wide-web at this URL: |
|
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
|
11
|
|
|
* |
|
12
|
|
|
* PHP version 5 |
|
13
|
|
|
* |
|
14
|
|
|
* @author Tim Wagner <[email protected]> |
|
15
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
|
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
17
|
|
|
* @link https://github.com/techdivision/import-attribute |
|
18
|
|
|
* @link http://www.techdivision.com |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Attribute\Observers; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Observer that exports the attribute options to an additional CSV file for further processing. |
|
25
|
|
|
* |
|
26
|
|
|
* @author Tim Wagner <[email protected]> |
|
27
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
|
28
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
29
|
|
|
* @link https://github.com/techdivision/import-attribute |
|
30
|
|
|
* @link http://www.techdivision.com |
|
31
|
|
|
*/ |
|
32
|
|
|
abstract class AbstractAttributeExportObserver extends AbstractAttributeImportObserver |
|
33
|
|
|
{ |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Return's the artefact type used for export. |
|
37
|
|
|
* |
|
38
|
|
|
* @return string The artefact type |
|
39
|
|
|
*/ |
|
40
|
|
|
abstract protected function getArtefactType(); |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Create's and return's a new empty artefact entity. |
|
44
|
|
|
* |
|
45
|
|
|
* @param array $columns The array with the column data |
|
46
|
|
|
* @param array $originalColumnNames The array with a mapping from the old to the new column names |
|
47
|
|
|
* |
|
48
|
|
|
* @return array The new artefact entity |
|
49
|
|
|
*/ |
|
50
|
|
|
protected function newArtefact(array $columns, array $originalColumnNames) |
|
51
|
|
|
{ |
|
52
|
|
|
return $this->getSubject()->newArtefact($columns, $originalColumnNames); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Add the passed product type artefacts to the product with the |
|
57
|
|
|
* last entity ID. |
|
58
|
|
|
* |
|
59
|
|
|
* @param array $artefacts The product type artefacts |
|
60
|
|
|
* |
|
61
|
|
|
* @return void |
|
62
|
|
|
* @uses \TechDivision\Import\Product\Bundle\Subjects\BunchSubject::getLastEntityId() |
|
63
|
|
|
*/ |
|
64
|
|
|
protected function addArtefacts(array $artefacts) |
|
65
|
|
|
{ |
|
66
|
|
|
$this->getSubject()->addArtefacts($this->getArtefactType(), $artefacts); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Return the artefacts for the passed type and entity ID. |
|
71
|
|
|
* |
|
72
|
|
|
* @param string $type The artefact type, e. g. configurable |
|
73
|
|
|
* @param string $entityId The entity ID to return the artefacts for |
|
74
|
|
|
* |
|
75
|
|
|
* @return array The array with the artefacts |
|
76
|
|
|
* @throws \Exception Is thrown, if no artefacts are available |
|
77
|
|
|
*/ |
|
78
|
|
|
protected function getArtefactsByTypeAndEntityId($type, $entityId) |
|
79
|
|
|
{ |
|
80
|
|
|
return $this->getSubject()->getArtefactsByTypeAndEntityId($type, $entityId); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|