1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* TechDivision\Import\Customer\Address\Subjects\AbstractAddressCustomerSubject |
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 2018 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-customer-address |
18
|
|
|
* @link http://www.techdivision.com |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Customer\Address\Subjects; |
22
|
|
|
|
23
|
|
|
use TechDivision\Import\Subjects\AbstractEavSubject; |
24
|
|
|
use TechDivision\Import\Subjects\EntitySubjectInterface; |
25
|
|
|
use TechDivision\Import\Customer\Address\Utils\MemberNames; |
26
|
|
|
use TechDivision\Import\Customer\Address\Utils\RegistryKeys; |
27
|
|
|
use TechDivision\Import\Customer\Address\Utils\ConfigurationKeys; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* The abstract customer subject implementation that provides basic customer address |
31
|
|
|
* handling business logic. |
32
|
|
|
* |
33
|
|
|
* @author Tim Wagner <[email protected]> |
34
|
|
|
* @copyright 2018 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-customer-address |
37
|
|
|
* @link http://www.techdivision.com |
38
|
|
|
*/ |
39
|
|
|
abstract class AbstractCustomerAddressSubject extends AbstractEavSubject implements EntitySubjectInterface |
40
|
|
|
{ |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* The ID of the product that has been created recently. |
44
|
|
|
* |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
protected $lastEntityId; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* The available store websites. |
51
|
|
|
* |
52
|
|
|
* @var array |
53
|
|
|
*/ |
54
|
|
|
protected $storeWebsites = array(); |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Set's the ID of the product that has been created recently. |
58
|
|
|
* |
59
|
|
|
* @param string $lastEntityId The entity ID |
60
|
|
|
* |
61
|
|
|
* @return void |
62
|
|
|
*/ |
63
|
|
|
public function setLastEntityId($lastEntityId) |
64
|
|
|
{ |
65
|
|
|
$this->lastEntityId = $lastEntityId; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Return's the ID of the product that has been created recently. |
70
|
|
|
* |
71
|
|
|
* @return string The entity Id |
72
|
|
|
*/ |
73
|
|
|
public function getLastEntityId() |
74
|
|
|
{ |
75
|
|
|
return $this->lastEntityId; |
|
|
|
|
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Queries whether or not the passed PK and store view code has already been processed. |
80
|
|
|
* |
81
|
|
|
* @param string $pk The PK to check been processed |
82
|
|
|
* @param string $storeViewCode The store view code to check been processed |
83
|
|
|
* |
84
|
|
|
* @return boolean TRUE if the PK and store view code has been processed, else FALSE |
85
|
|
|
*/ |
86
|
|
|
public function storeViewHasBeenProcessed($pk, $storeViewCode) |
|
|
|
|
87
|
|
|
{ |
88
|
|
|
return false; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Intializes the previously loaded global data for exactly one bunch. |
93
|
|
|
* |
94
|
|
|
* @param string $serial The serial of the actual import |
95
|
|
|
* |
96
|
|
|
* @return void |
97
|
|
|
*/ |
98
|
|
|
public function setUp($serial) |
99
|
|
|
{ |
100
|
|
|
|
101
|
|
|
// load the status of the actual import |
102
|
|
|
$status = $this->getRegistryProcessor()->getAttribute($serial); |
103
|
|
|
|
104
|
|
|
// load the global data we've prepared initially |
105
|
|
|
$this->storeWebsites = $status[RegistryKeys::GLOBAL_DATA][RegistryKeys::STORE_WEBSITES]; |
106
|
|
|
|
107
|
|
|
// invoke the parent method |
108
|
|
|
parent::setUp($serial); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Return's the store website for the passed code. |
113
|
|
|
* |
114
|
|
|
* @param string $code The code of the store website to return the ID for |
115
|
|
|
* |
116
|
|
|
* @return integer The store website ID |
117
|
|
|
* @throws \Exception Is thrown, if the store website with the requested code is not available |
118
|
|
|
*/ |
119
|
|
|
public function getStoreWebsiteIdByCode($code) |
120
|
|
|
{ |
121
|
|
|
|
122
|
|
|
// query whether or not, the requested store website is available |
123
|
|
|
if (isset($this->storeWebsites[$code])) { |
124
|
|
|
return (integer) $this->storeWebsites[$code][MemberNames::WEBSITE_ID]; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
// throw an exception, if not |
128
|
|
|
throw new \Exception( |
129
|
|
|
$this->appendExceptionSuffix( |
130
|
|
|
sprintf('Found invalid website code %s', $code) |
131
|
|
|
) |
132
|
|
|
); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Merge the columns from the configuration with all image type columns to define which |
137
|
|
|
* columns should be cleaned-up. |
138
|
|
|
* |
139
|
|
|
* @return array The columns that has to be cleaned-up |
140
|
|
|
*/ |
141
|
|
|
public function getCleanUpColumns() |
142
|
|
|
{ |
143
|
|
|
return $this->getConfiguration()->getParam(ConfigurationKeys::CLEAN_UP_EMPTY_COLUMNS); |
|
|
|
|
144
|
|
|
} |
145
|
|
|
} |
146
|
|
|
|
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: