|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Category\Ee\Subjects\EeBunchSubject |
|
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-category-ee |
|
18
|
|
|
* @link http://www.techdivision.com |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Category\Ee\Subjects; |
|
22
|
|
|
|
|
23
|
|
|
use TechDivision\Import\Utils\RegistryKeys; |
|
24
|
|
|
use TechDivision\Import\Category\Subjects\BunchSubject; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* A SLSB that handles the process to import category bunches. |
|
28
|
|
|
* |
|
29
|
|
|
* @author Tim Wagner <[email protected]> |
|
30
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
|
31
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
32
|
|
|
* @link https://github.com/techdivision/import-category-ee |
|
33
|
|
|
* @link http://www.techdivision.com |
|
34
|
|
|
*/ |
|
35
|
|
|
class EeBunchSubject extends BunchSubject |
|
36
|
|
|
{ |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* The row ID of the product that has been created recently. |
|
40
|
|
|
* |
|
41
|
|
|
* @var integer |
|
42
|
|
|
*/ |
|
43
|
|
|
protected $lastRowId; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* The mapping for the paths to the created row IDs. |
|
47
|
|
|
* |
|
48
|
|
|
* @var array |
|
49
|
|
|
*/ |
|
50
|
|
|
protected $pathRowIdMapping = array(); |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* The mapping for the supported backend types (for the product entity) => persist methods. |
|
54
|
|
|
* |
|
55
|
|
|
* @var array |
|
56
|
|
|
*/ |
|
57
|
|
|
protected $backendTypes = array( |
|
58
|
|
|
'datetime' => array('persistDatetimeAttribute', 'loadCategoryDatetimeAttributeByRowIdAndAttributeIdAndStoreId'), |
|
59
|
|
|
'decimal' => array('persistDecimalAttribute', 'loadCategoryDecimalAttributeByRowIdAndAttributeIdAndStoreId'), |
|
60
|
|
|
'int' => array('persistIntAttribute', 'loadCategoryIntAttributeByRowIdAndAttributeIdAndStoreId'), |
|
61
|
|
|
'text' => array('persistTextAttribute', 'loadCategoryTextAttributeByRowIdAndAttributeIdAndStoreId'), |
|
62
|
|
|
'varchar' => array('persistVarcharAttribute', 'loadCategoryVarcharAttributeByRowIdAndAttributeIdAndStoreId') |
|
63
|
|
|
); |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Clean up the global data after importing the bunch. |
|
67
|
|
|
* |
|
68
|
|
|
* @param string $serial The serial of the actual import |
|
69
|
|
|
* |
|
70
|
|
|
* @return void |
|
71
|
|
|
*/ |
|
72
|
|
|
public function tearDown($serial) |
|
73
|
|
|
{ |
|
74
|
|
|
|
|
75
|
|
|
// call parent method |
|
76
|
|
|
parent::tearDown($serial); |
|
77
|
|
|
|
|
78
|
|
|
// load the registry processor |
|
79
|
|
|
$registryProcessor = $this->getRegistryProcessor(); |
|
80
|
|
|
|
|
81
|
|
|
// update the status up the actual import with SKU => row ID mapping |
|
82
|
|
|
$registryProcessor->mergeAttributesRecursive($this->serial, array(RegistryKeys::PATH_ROW_ID_MAPPING => $this->pathRowIdMapping)); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Set's the row ID of the product that has been created recently. |
|
87
|
|
|
* |
|
88
|
|
|
* @param string $lastRowId The row ID |
|
89
|
|
|
* |
|
90
|
|
|
* @return void |
|
91
|
|
|
*/ |
|
92
|
1 |
|
public function setLastRowId($lastRowId) |
|
93
|
|
|
{ |
|
94
|
1 |
|
$this->lastRowId = $lastRowId; |
|
|
|
|
|
|
95
|
1 |
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Return's the row ID of the product that has been created recently. |
|
99
|
|
|
* |
|
100
|
|
|
* @return string The row Id |
|
101
|
|
|
*/ |
|
102
|
1 |
|
public function getLastRowId() |
|
103
|
|
|
{ |
|
104
|
1 |
|
return $this->lastRowId; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* Add the passed path => row ID mapping. |
|
109
|
|
|
* |
|
110
|
|
|
* @param string $path The path |
|
111
|
|
|
* |
|
112
|
|
|
* @return void |
|
113
|
|
|
*/ |
|
114
|
|
|
public function addPathRowIdMapping($path) |
|
115
|
|
|
{ |
|
116
|
|
|
$this->pathRowIdMapping[$path] = $this->getLastRowId(); |
|
117
|
|
|
} |
|
118
|
|
|
} |
|
119
|
|
|
|
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.