|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Converter\Subjects\ConverterSubject |
|
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-converter |
|
18
|
|
|
* @link http://www.techdivision.com |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Converter\Subjects; |
|
22
|
|
|
|
|
23
|
|
|
use TechDivision\Import\Subjects\ExportableTrait; |
|
24
|
|
|
use TechDivision\Import\Subjects\AbstractEavSubject; |
|
25
|
|
|
use TechDivision\Import\Subjects\NumberConverterTrait; |
|
26
|
|
|
use TechDivision\Import\Subjects\ExportableSubjectInterface; |
|
27
|
|
|
use TechDivision\Import\Subjects\NumberConverterSubjectInterface; |
|
28
|
|
|
use TechDivision\Import\Subjects\FilesystemSubjectInterface; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Converter subject implementation. |
|
32
|
|
|
* |
|
33
|
|
|
* @author Tim Wagner <[email protected]> |
|
34
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
|
35
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
36
|
|
|
* @link https://github.com/techdivision/import-converter |
|
37
|
|
|
* @link http://www.techdivision.com |
|
38
|
|
|
*/ |
|
39
|
|
|
class ConverterSubject extends AbstractEavSubject implements ExportableSubjectInterface, NumberConverterSubjectInterface, FilesystemSubjectInterface |
|
40
|
|
|
{ |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* The trait that implements the export functionality. |
|
44
|
|
|
* |
|
45
|
|
|
* @var \TechDivision\Import\Subjects\ExportableTrait |
|
46
|
|
|
*/ |
|
47
|
|
|
use ExportableTrait; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* The trait that implements the number converter functionality. |
|
51
|
|
|
* |
|
52
|
|
|
* @var \TechDivision\Import\Subjects\NumberConverterTrait |
|
53
|
|
|
*/ |
|
54
|
|
|
use NumberConverterTrait; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* The SKU of the product that has been created recently. |
|
58
|
|
|
* |
|
59
|
|
|
* @var string |
|
60
|
|
|
*/ |
|
61
|
|
|
protected $lastSku; |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* The mapping for the SKUs to the created entity IDs. |
|
65
|
|
|
* |
|
66
|
|
|
* @var array |
|
67
|
|
|
*/ |
|
68
|
|
|
protected $skuEntityIdMapping = array(); |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* The mapping for the SKUs to the store view codes. |
|
72
|
|
|
* |
|
73
|
|
|
* @var array |
|
74
|
|
|
*/ |
|
75
|
|
|
protected $skuStoreViewCodeMapping = array(); |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Set's the SKU of the last imported product. |
|
79
|
|
|
* |
|
80
|
|
|
* @param string $lastSku The SKU |
|
81
|
|
|
* |
|
82
|
|
|
* @return void |
|
83
|
|
|
*/ |
|
84
|
|
|
public function setLastSku($lastSku) |
|
85
|
|
|
{ |
|
86
|
|
|
$this->lastSku = $lastSku; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Return's the SKU of the last imported product. |
|
91
|
|
|
* |
|
92
|
|
|
* @return string|null The SKU |
|
93
|
|
|
*/ |
|
94
|
|
|
public function getLastSku() |
|
95
|
|
|
{ |
|
96
|
|
|
return $this->lastSku; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Add the passed SKU => entity ID mapping. |
|
101
|
|
|
* |
|
102
|
|
|
* @param string $sku The SKU |
|
103
|
|
|
* |
|
104
|
|
|
* @return void |
|
105
|
|
|
*/ |
|
106
|
|
|
public function addSkuEntityIdMapping($sku) |
|
107
|
|
|
{ |
|
108
|
|
|
$this->skuEntityIdMapping[$sku] = $this->getLastEntityId(); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* Add the passed SKU => store view code mapping. |
|
113
|
|
|
* |
|
114
|
|
|
* @param string $sku The SKU |
|
115
|
|
|
* @param string $storeViewCode The store view code |
|
116
|
|
|
* |
|
117
|
|
|
* @return void |
|
118
|
|
|
*/ |
|
119
|
|
|
public function addSkuStoreViewCodeMapping($sku, $storeViewCode) |
|
120
|
|
|
{ |
|
121
|
|
|
$this->skuStoreViewCodeMapping[$sku][] = $storeViewCode; |
|
122
|
|
|
} |
|
123
|
|
|
} |
|
124
|
|
|
|