1 | <?php |
||
36 | abstract class AbstractProductImportObserver extends AbstractObserver implements ProductImportObserverInterface |
||
37 | { |
||
38 | |||
39 | /** |
||
40 | * The actual row, that has to be processed. |
||
41 | * |
||
42 | * @var array |
||
43 | */ |
||
44 | protected $row = array(); |
||
45 | |||
46 | /** |
||
47 | * Set's the array containing header row. |
||
48 | * |
||
49 | * @param array $headers The array with the header row |
||
50 | * |
||
51 | * @return void |
||
52 | */ |
||
53 | public function setHeaders(array $headers) |
||
57 | |||
58 | /** |
||
59 | * Return's the array containing header row. |
||
60 | * |
||
61 | * @return array The array with the header row |
||
62 | */ |
||
63 | 7 | public function getHeaders() |
|
67 | |||
68 | /** |
||
69 | * Return's TRUE if the passed SKU is the actual one. |
||
70 | * |
||
71 | * @param string $sku The SKU to check |
||
72 | * |
||
73 | * @return boolean TRUE if the passed SKU is the actual one |
||
74 | */ |
||
75 | 7 | public function isLastSku($sku) |
|
79 | |||
80 | /** |
||
81 | * Return's the ID of the product that has been created recently. |
||
82 | * |
||
83 | * @return string The entity Id |
||
84 | */ |
||
85 | 3 | public function getLastEntityId() |
|
89 | |||
90 | /** |
||
91 | * Return's the source date format to use. |
||
92 | * |
||
93 | * @return string The source date format |
||
94 | */ |
||
95 | 1 | public function getSourceDateFormat() |
|
99 | |||
100 | /** |
||
101 | * Cast's the passed value based on the backend type information. |
||
102 | * |
||
103 | * @param string $backendType The backend type to cast to |
||
104 | * @param mixed $value The value to be casted |
||
105 | * |
||
106 | * @return mixed The casted value |
||
107 | */ |
||
108 | public function castValueByBackendType($backendType, $value) |
||
112 | |||
113 | /** |
||
114 | * Set's the store view code the create the product/attributes for. |
||
115 | * |
||
116 | * @param string $storeViewCode The store view code |
||
117 | * |
||
118 | * @return void |
||
119 | */ |
||
120 | 3 | public function setStoreViewCode($storeViewCode) |
|
124 | |||
125 | /** |
||
126 | * Return's the store view code the create the product/attributes for. |
||
127 | * |
||
128 | * @param string|null $default The default value to return, if the store view code has not been set |
||
129 | * |
||
130 | * @return string The store view code |
||
131 | */ |
||
132 | public function getStoreViewCode($default = null) |
||
136 | |||
137 | /** |
||
138 | * Prepare's the store view code in the subject. |
||
139 | * |
||
140 | * @return void |
||
141 | */ |
||
142 | 3 | public function prepareStoreViewCode() |
|
160 | |||
161 | /** |
||
162 | * Set's the actual row, that has to be processed. |
||
163 | * |
||
164 | * @param array $row The row |
||
165 | * |
||
166 | * @return void |
||
167 | */ |
||
168 | 6 | public function setRow(array $row) |
|
172 | |||
173 | /** |
||
174 | * Return's the actual row, that has to be processed. |
||
175 | * |
||
176 | * @return array The row |
||
177 | */ |
||
178 | 6 | public function getRow() |
|
182 | |||
183 | /** |
||
184 | * Tries to format the passed value to a valid date with format 'Y-m-d H:i:s'. |
||
185 | * If the passed value is NOT a valid date, NULL will be returned. |
||
186 | * |
||
187 | * @param string|null $value The value to format |
||
188 | * |
||
189 | * @return string The formatted date |
||
190 | */ |
||
191 | 1 | public function formatDate($value) |
|
202 | |||
203 | /** |
||
204 | * Query whether or not the value with the passed key exists. |
||
205 | * |
||
206 | * @param string $key The key of the value to query |
||
207 | * |
||
208 | * @return boolean TRUE if the value is set, else FALSE |
||
209 | */ |
||
210 | 2 | public function hasValue($key) |
|
220 | |||
221 | /** |
||
222 | * Resolve's the value with the passed key from the actual row. If a callback will |
||
223 | * be passed, the callback will be invoked with the found value as parameter. If |
||
224 | * the value is NULL or empty, the default value will be returned. |
||
225 | * |
||
226 | * @param string $key The key of the value to return |
||
227 | * @param mixed|null $default The default value, that has to be returned, if the row's value is empty |
||
228 | * @param callable|null $callback The callback that has to be invoked on the value, e. g. to format it |
||
229 | * |
||
230 | * @return mixed|null The, almost formatted, value |
||
231 | */ |
||
232 | 6 | public function getValue($key, $default = null, callable $callback = null) |
|
260 | |||
261 | /** |
||
262 | * Initialize's and return's a new entity with the status 'create'. |
||
263 | * |
||
264 | * @param array $attr The attributes to merge into the new entity |
||
265 | * |
||
266 | * @return array The initialized entity |
||
267 | */ |
||
268 | 4 | public function initializeEntity(array $attr = array()) |
|
272 | |||
273 | /** |
||
274 | * Merge's and return's the entity with the passed attributes and set's the |
||
275 | * status to 'update'. |
||
276 | * |
||
277 | * @param array $entity The entity to merge the attributes into |
||
278 | * @param array $attr The attributes to be merged |
||
279 | * |
||
280 | * @return array The merged entity |
||
281 | */ |
||
282 | 2 | public function mergeEntity(array $entity, array $attr) |
|
286 | } |
||
287 |