@@ -21,10 +21,10 @@ discard block |
||
21 | 21 | */ |
22 | 22 | protected function setUp() |
23 | 23 | { |
24 | - \Aimeos\MShop\Factory::setCache( true ); |
|
24 | + \Aimeos\MShop\Factory::setCache(true); |
|
25 | 25 | |
26 | 26 | $this->context = \TestHelperCntl::getContext(); |
27 | - $this->endpoint = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done( $this->context, [] ); |
|
27 | + $this->endpoint = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done($this->context, []); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | protected function tearDown() |
38 | 38 | { |
39 | - \Aimeos\MShop\Factory::setCache( false ); |
|
39 | + \Aimeos\MShop\Factory::setCache(false); |
|
40 | 40 | \Aimeos\MShop\Factory::clear(); |
41 | 41 | } |
42 | 42 | |
@@ -61,36 +61,36 @@ discard block |
||
61 | 61 | 5 => 1, |
62 | 62 | ); |
63 | 63 | |
64 | - $product = $this->create( 'job_csv_test' ); |
|
64 | + $product = $this->create('job_csv_test'); |
|
65 | 65 | |
66 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Media\Standard( $this->context, $mapping, $this->endpoint ); |
|
67 | - $object->process( $product, $data ); |
|
66 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Media\Standard($this->context, $mapping, $this->endpoint); |
|
67 | + $object->process($product, $data); |
|
68 | 68 | |
69 | - $product = $this->get( 'job_csv_test' ); |
|
70 | - $this->delete( $product ); |
|
69 | + $product = $this->get('job_csv_test'); |
|
70 | + $this->delete($product); |
|
71 | 71 | |
72 | 72 | |
73 | 73 | $listItems = $product->getListItems(); |
74 | - $listItem = reset( $listItems ); |
|
74 | + $listItem = reset($listItems); |
|
75 | 75 | |
76 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem ); |
|
77 | - $this->assertEquals( 1, count( $listItems ) ); |
|
76 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem); |
|
77 | + $this->assertEquals(1, count($listItems)); |
|
78 | 78 | |
79 | - $this->assertEquals( 1, $listItem->getStatus() ); |
|
80 | - $this->assertEquals( 0, $listItem->getPosition() ); |
|
81 | - $this->assertEquals( 'media', $listItem->getDomain() ); |
|
82 | - $this->assertEquals( 'default', $listItem->getType() ); |
|
79 | + $this->assertEquals(1, $listItem->getStatus()); |
|
80 | + $this->assertEquals(0, $listItem->getPosition()); |
|
81 | + $this->assertEquals('media', $listItem->getDomain()); |
|
82 | + $this->assertEquals('default', $listItem->getType()); |
|
83 | 83 | |
84 | 84 | $refItem = $listItem->getRefItem(); |
85 | 85 | |
86 | - $this->assertEquals( 1, $refItem->getStatus() ); |
|
87 | - $this->assertEquals( 'default', $refItem->getType() ); |
|
88 | - $this->assertEquals( 'product', $refItem->getDomain() ); |
|
89 | - $this->assertEquals( 'test image', $refItem->getLabel() ); |
|
90 | - $this->assertEquals( 'image/jpeg', $refItem->getMimetype() ); |
|
91 | - $this->assertEquals( 'path/to/preview', $refItem->getPreview() ); |
|
92 | - $this->assertEquals( 'path/to/file', $refItem->getUrl() ); |
|
93 | - $this->assertEquals( 'de', $refItem->getLanguageId() ); |
|
86 | + $this->assertEquals(1, $refItem->getStatus()); |
|
87 | + $this->assertEquals('default', $refItem->getType()); |
|
88 | + $this->assertEquals('product', $refItem->getDomain()); |
|
89 | + $this->assertEquals('test image', $refItem->getLabel()); |
|
90 | + $this->assertEquals('image/jpeg', $refItem->getMimetype()); |
|
91 | + $this->assertEquals('path/to/preview', $refItem->getPreview()); |
|
92 | + $this->assertEquals('path/to/file', $refItem->getUrl()); |
|
93 | + $this->assertEquals('de', $refItem->getLanguageId()); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | |
@@ -104,24 +104,24 @@ discard block |
||
104 | 104 | 0 => "path/to/0\npath/to/1\npath/to/2\npath/to/3", |
105 | 105 | ); |
106 | 106 | |
107 | - $product = $this->create( 'job_csv_test' ); |
|
107 | + $product = $this->create('job_csv_test'); |
|
108 | 108 | |
109 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Media\Standard( $this->context, $mapping, $this->endpoint ); |
|
110 | - $object->process( $product, $data ); |
|
109 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Media\Standard($this->context, $mapping, $this->endpoint); |
|
110 | + $object->process($product, $data); |
|
111 | 111 | |
112 | - $product = $this->get( 'job_csv_test' ); |
|
113 | - $this->delete( $product ); |
|
112 | + $product = $this->get('job_csv_test'); |
|
113 | + $this->delete($product); |
|
114 | 114 | |
115 | 115 | |
116 | 116 | $pos = 0; |
117 | 117 | $listItems = $product->getListItems(); |
118 | - $expected = array( 'path/to/0', 'path/to/1', 'path/to/2', 'path/to/3' ); |
|
118 | + $expected = array('path/to/0', 'path/to/1', 'path/to/2', 'path/to/3'); |
|
119 | 119 | |
120 | - $this->assertEquals( 4, count( $listItems ) ); |
|
120 | + $this->assertEquals(4, count($listItems)); |
|
121 | 121 | |
122 | - foreach( $listItems as $listItem ) |
|
122 | + foreach ($listItems as $listItem) |
|
123 | 123 | { |
124 | - $this->assertEquals( $expected[$pos], $listItem->getRefItem()->getUrl() ); |
|
124 | + $this->assertEquals($expected[$pos], $listItem->getRefItem()->getUrl()); |
|
125 | 125 | $pos++; |
126 | 126 | } |
127 | 127 | } |
@@ -143,23 +143,23 @@ discard block |
||
143 | 143 | 3 => 'path/to/3', |
144 | 144 | ); |
145 | 145 | |
146 | - $product = $this->create( 'job_csv_test' ); |
|
146 | + $product = $this->create('job_csv_test'); |
|
147 | 147 | |
148 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Media\Standard( $this->context, $mapping, $this->endpoint ); |
|
149 | - $object->process( $product, $data ); |
|
148 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Media\Standard($this->context, $mapping, $this->endpoint); |
|
149 | + $object->process($product, $data); |
|
150 | 150 | |
151 | - $product = $this->get( 'job_csv_test' ); |
|
152 | - $this->delete( $product ); |
|
151 | + $product = $this->get('job_csv_test'); |
|
152 | + $this->delete($product); |
|
153 | 153 | |
154 | 154 | |
155 | 155 | $pos = 0; |
156 | 156 | $listItems = $product->getListItems(); |
157 | 157 | |
158 | - $this->assertEquals( 4, count( $listItems ) ); |
|
158 | + $this->assertEquals(4, count($listItems)); |
|
159 | 159 | |
160 | - foreach( $listItems as $listItem ) |
|
160 | + foreach ($listItems as $listItem) |
|
161 | 161 | { |
162 | - $this->assertEquals( $data[$pos], $listItem->getRefItem()->getUrl() ); |
|
162 | + $this->assertEquals($data[$pos], $listItem->getRefItem()->getUrl()); |
|
163 | 163 | $pos++; |
164 | 164 | } |
165 | 165 | } |
@@ -182,27 +182,27 @@ discard block |
||
182 | 182 | 1 => '', |
183 | 183 | ); |
184 | 184 | |
185 | - $product = $this->create( 'job_csv_test' ); |
|
185 | + $product = $this->create('job_csv_test'); |
|
186 | 186 | |
187 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Media\Standard( $this->context, $mapping, $this->endpoint ); |
|
188 | - $object->process( $product, $data ); |
|
187 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Media\Standard($this->context, $mapping, $this->endpoint); |
|
188 | + $object->process($product, $data); |
|
189 | 189 | |
190 | - $product = $this->get( 'job_csv_test' ); |
|
190 | + $product = $this->get('job_csv_test'); |
|
191 | 191 | |
192 | - $object->process( $product, $dataUpdate ); |
|
192 | + $object->process($product, $dataUpdate); |
|
193 | 193 | |
194 | - $product = $this->get( 'job_csv_test' ); |
|
195 | - $this->delete( $product ); |
|
194 | + $product = $this->get('job_csv_test'); |
|
195 | + $this->delete($product); |
|
196 | 196 | |
197 | 197 | |
198 | 198 | $listItems = $product->getListItems(); |
199 | - $listItem = reset( $listItems ); |
|
199 | + $listItem = reset($listItems); |
|
200 | 200 | |
201 | - $this->assertEquals( 1, count( $listItems ) ); |
|
202 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem ); |
|
201 | + $this->assertEquals(1, count($listItems)); |
|
202 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem); |
|
203 | 203 | |
204 | - $this->assertEquals( 'path/to/new', $listItem->getRefItem()->getUrl() ); |
|
205 | - $this->assertEquals( null, $listItem->getRefItem()->getLanguageId() ); |
|
204 | + $this->assertEquals('path/to/new', $listItem->getRefItem()->getUrl()); |
|
205 | + $this->assertEquals(null, $listItem->getRefItem()->getLanguageId()); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | |
@@ -216,23 +216,23 @@ discard block |
||
216 | 216 | 0 => '/path/to/file', |
217 | 217 | ); |
218 | 218 | |
219 | - $product = $this->create( 'job_csv_test' ); |
|
219 | + $product = $this->create('job_csv_test'); |
|
220 | 220 | |
221 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Media\Standard( $this->context, $mapping, $this->endpoint ); |
|
222 | - $object->process( $product, $data ); |
|
221 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Media\Standard($this->context, $mapping, $this->endpoint); |
|
222 | + $object->process($product, $data); |
|
223 | 223 | |
224 | - $product = $this->get( 'job_csv_test' ); |
|
224 | + $product = $this->get('job_csv_test'); |
|
225 | 225 | |
226 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Media\Standard( $this->context, [], $this->endpoint ); |
|
227 | - $object->process( $product, [] ); |
|
226 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Media\Standard($this->context, [], $this->endpoint); |
|
227 | + $object->process($product, []); |
|
228 | 228 | |
229 | - $product = $this->get( 'job_csv_test' ); |
|
230 | - $this->delete( $product ); |
|
229 | + $product = $this->get('job_csv_test'); |
|
230 | + $this->delete($product); |
|
231 | 231 | |
232 | 232 | |
233 | 233 | $listItems = $product->getListItems(); |
234 | 234 | |
235 | - $this->assertEquals( 0, count( $listItems ) ); |
|
235 | + $this->assertEquals(0, count($listItems)); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | |
@@ -248,18 +248,18 @@ discard block |
||
248 | 248 | 1 => '', |
249 | 249 | ); |
250 | 250 | |
251 | - $product = $this->create( 'job_csv_test' ); |
|
251 | + $product = $this->create('job_csv_test'); |
|
252 | 252 | |
253 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Media\Standard( $this->context, $mapping, $this->endpoint ); |
|
254 | - $object->process( $product, $data ); |
|
253 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Media\Standard($this->context, $mapping, $this->endpoint); |
|
254 | + $object->process($product, $data); |
|
255 | 255 | |
256 | - $product = $this->get( 'job_csv_test' ); |
|
257 | - $this->delete( $product ); |
|
256 | + $product = $this->get('job_csv_test'); |
|
257 | + $this->delete($product); |
|
258 | 258 | |
259 | 259 | |
260 | 260 | $listItems = $product->getListItems(); |
261 | 261 | |
262 | - $this->assertEquals( 1, count( $listItems ) ); |
|
262 | + $this->assertEquals(1, count($listItems)); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | |
@@ -279,84 +279,84 @@ discard block |
||
279 | 279 | 3 => 'default', |
280 | 280 | ); |
281 | 281 | |
282 | - $this->context->getConfig()->set( 'controller/common/product/import/csv/processor/media/listtypes', array( 'default' ) ); |
|
282 | + $this->context->getConfig()->set('controller/common/product/import/csv/processor/media/listtypes', array('default')); |
|
283 | 283 | |
284 | - $product = $this->create( 'job_csv_test' ); |
|
284 | + $product = $this->create('job_csv_test'); |
|
285 | 285 | |
286 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Media\Standard( $this->context, $mapping, $this->endpoint ); |
|
287 | - $object->process( $product, $data ); |
|
286 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Media\Standard($this->context, $mapping, $this->endpoint); |
|
287 | + $object->process($product, $data); |
|
288 | 288 | |
289 | - $product = $this->get( 'job_csv_test' ); |
|
290 | - $this->delete( $product ); |
|
289 | + $product = $this->get('job_csv_test'); |
|
290 | + $this->delete($product); |
|
291 | 291 | |
292 | 292 | |
293 | 293 | $listItems = $product->getListItems(); |
294 | - $listItem = reset( $listItems ); |
|
294 | + $listItem = reset($listItems); |
|
295 | 295 | |
296 | - $this->assertEquals( 1, count( $listItems ) ); |
|
297 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem ); |
|
296 | + $this->assertEquals(1, count($listItems)); |
|
297 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem); |
|
298 | 298 | |
299 | - $this->assertEquals( 'default', $listItem->getType() ); |
|
300 | - $this->assertEquals( 'path/to/file2', $listItem->getRefItem()->getUrl() ); |
|
299 | + $this->assertEquals('default', $listItem->getType()); |
|
300 | + $this->assertEquals('path/to/file2', $listItem->getRefItem()->getUrl()); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
304 | 304 | /** |
305 | 305 | * @param string $code |
306 | 306 | */ |
307 | - protected function create( $code ) |
|
307 | + protected function create($code) |
|
308 | 308 | { |
309 | - $manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context ); |
|
310 | - $typeManager = $manager->getSubManager( 'type' ); |
|
309 | + $manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context); |
|
310 | + $typeManager = $manager->getSubManager('type'); |
|
311 | 311 | |
312 | 312 | $typeSearch = $typeManager->createSearch(); |
313 | - $typeSearch->setConditions( $typeSearch->compare( '==', 'product.type.code', 'default' ) ); |
|
314 | - $typeResult = $typeManager->searchItems( $typeSearch ); |
|
313 | + $typeSearch->setConditions($typeSearch->compare('==', 'product.type.code', 'default')); |
|
314 | + $typeResult = $typeManager->searchItems($typeSearch); |
|
315 | 315 | |
316 | - if( ( $typeItem = reset( $typeResult ) ) === false ) { |
|
317 | - throw new \RuntimeException( 'No product type "default" found' ); |
|
316 | + if (($typeItem = reset($typeResult)) === false) { |
|
317 | + throw new \RuntimeException('No product type "default" found'); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | $item = $manager->createItem(); |
321 | - $item->setTypeid( $typeItem->getId() ); |
|
322 | - $item->setCode( $code ); |
|
321 | + $item->setTypeid($typeItem->getId()); |
|
322 | + $item->setCode($code); |
|
323 | 323 | |
324 | - $manager->saveItem( $item ); |
|
324 | + $manager->saveItem($item); |
|
325 | 325 | |
326 | 326 | return $item; |
327 | 327 | } |
328 | 328 | |
329 | 329 | |
330 | - protected function delete( \Aimeos\MShop\Product\Item\Iface $product ) |
|
330 | + protected function delete(\Aimeos\MShop\Product\Item\Iface $product) |
|
331 | 331 | { |
332 | - $mediaManager = \Aimeos\MShop\Media\Manager\Factory::createManager( $this->context ); |
|
333 | - $manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context ); |
|
334 | - $listManager = $manager->getSubManager( 'lists' ); |
|
332 | + $mediaManager = \Aimeos\MShop\Media\Manager\Factory::createManager($this->context); |
|
333 | + $manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context); |
|
334 | + $listManager = $manager->getSubManager('lists'); |
|
335 | 335 | |
336 | - foreach( $product->getListItems('media') as $listItem ) |
|
336 | + foreach ($product->getListItems('media') as $listItem) |
|
337 | 337 | { |
338 | - $mediaManager->deleteItem( $listItem->getRefItem()->getId() ); |
|
339 | - $listManager->deleteItem( $listItem->getId() ); |
|
338 | + $mediaManager->deleteItem($listItem->getRefItem()->getId()); |
|
339 | + $listManager->deleteItem($listItem->getId()); |
|
340 | 340 | } |
341 | 341 | |
342 | - $manager->deleteItem( $product->getId() ); |
|
342 | + $manager->deleteItem($product->getId()); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | |
346 | 346 | /** |
347 | 347 | * @param string $code |
348 | 348 | */ |
349 | - protected function get( $code ) |
|
349 | + protected function get($code) |
|
350 | 350 | { |
351 | - $manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context ); |
|
351 | + $manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context); |
|
352 | 352 | |
353 | 353 | $search = $manager->createSearch(); |
354 | - $search->setConditions( $search->compare( '==', 'product.code', $code ) ); |
|
354 | + $search->setConditions($search->compare('==', 'product.code', $code)); |
|
355 | 355 | |
356 | - $result = $manager->searchItems( $search, array('media') ); |
|
356 | + $result = $manager->searchItems($search, array('media')); |
|
357 | 357 | |
358 | - if( ( $item = reset( $result ) ) === false ) { |
|
359 | - throw new \RuntimeException( sprintf( 'No product item for code "%1$s"', $code ) ); |
|
358 | + if (($item = reset($result)) === false) { |
|
359 | + throw new \RuntimeException(sprintf('No product item for code "%1$s"', $code)); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | return $item; |
@@ -21,10 +21,10 @@ discard block |
||
21 | 21 | */ |
22 | 22 | protected function setUp() |
23 | 23 | { |
24 | - \Aimeos\MShop\Factory::setCache( true ); |
|
24 | + \Aimeos\MShop\Factory::setCache(true); |
|
25 | 25 | |
26 | 26 | $this->context = \TestHelperCntl::getContext(); |
27 | - $this->object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done( $this->context, [] ); |
|
27 | + $this->object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done($this->context, []); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | protected function tearDown() |
38 | 38 | { |
39 | - \Aimeos\MShop\Factory::setCache( false ); |
|
39 | + \Aimeos\MShop\Factory::setCache(false); |
|
40 | 40 | \Aimeos\MShop\Factory::clear(); |
41 | 41 | |
42 | 42 | $this->object = null; |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | |
46 | 46 | public function testProcess() |
47 | 47 | { |
48 | - $product = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->createItem(); |
|
48 | + $product = \Aimeos\MShop\Factory::createManager($this->context, 'product')->createItem(); |
|
49 | 49 | |
50 | - $result = $this->object->process( $product, array( 'test' ) ); |
|
50 | + $result = $this->object->process($product, array('test')); |
|
51 | 51 | |
52 | - $this->assertEquals( array( 'test' ), $result ); |
|
52 | + $this->assertEquals(array('test'), $result); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | \ No newline at end of file |
@@ -17,16 +17,16 @@ discard block |
||
17 | 17 | |
18 | 18 | protected function setUp() |
19 | 19 | { |
20 | - \Aimeos\MShop\Factory::setCache( true ); |
|
20 | + \Aimeos\MShop\Factory::setCache(true); |
|
21 | 21 | |
22 | 22 | $this->context = \TestHelperCntl::getContext(); |
23 | - $this->endpoint = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done( $this->context, [] ); |
|
23 | + $this->endpoint = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done($this->context, []); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | |
27 | 27 | protected function tearDown() |
28 | 28 | { |
29 | - \Aimeos\MShop\Factory::setCache( false ); |
|
29 | + \Aimeos\MShop\Factory::setCache(false); |
|
30 | 30 | \Aimeos\MShop\Factory::clear(); |
31 | 31 | } |
32 | 32 | |
@@ -43,21 +43,21 @@ discard block |
||
43 | 43 | 1 => '2000-01-01 00:00:00', |
44 | 44 | ); |
45 | 45 | |
46 | - $product = $this->create( 'job_csv_test' ); |
|
46 | + $product = $this->create('job_csv_test'); |
|
47 | 47 | |
48 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard( $this->context, $mapping, $this->endpoint ); |
|
49 | - $object->process( $product, $data ); |
|
48 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard($this->context, $mapping, $this->endpoint); |
|
49 | + $object->process($product, $data); |
|
50 | 50 | |
51 | - $items = $this->getStockItems( $product->getCode() ); |
|
52 | - $this->delete( $product ); |
|
51 | + $items = $this->getStockItems($product->getCode()); |
|
52 | + $this->delete($product); |
|
53 | 53 | |
54 | 54 | |
55 | - $this->assertEquals( 1, count( $items ) ); |
|
55 | + $this->assertEquals(1, count($items)); |
|
56 | 56 | |
57 | - foreach( $items as $item ) |
|
57 | + foreach ($items as $item) |
|
58 | 58 | { |
59 | - $this->assertEquals( 100, $item->getStocklevel() ); |
|
60 | - $this->assertEquals( '2000-01-01 00:00:00', $item->getDateBack() ); |
|
59 | + $this->assertEquals(100, $item->getStocklevel()); |
|
60 | + $this->assertEquals('2000-01-01 00:00:00', $item->getDateBack()); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
@@ -78,19 +78,19 @@ discard block |
||
78 | 78 | 3 => '200', |
79 | 79 | ); |
80 | 80 | |
81 | - $product = $this->create( 'job_csv_test' ); |
|
81 | + $product = $this->create('job_csv_test'); |
|
82 | 82 | |
83 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard( $this->context, $mapping, $this->endpoint ); |
|
84 | - $object->process( $product, $data ); |
|
83 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard($this->context, $mapping, $this->endpoint); |
|
84 | + $object->process($product, $data); |
|
85 | 85 | |
86 | - $items = $this->getStockItems( $product->getCode() ); |
|
87 | - $this->delete( $product ); |
|
86 | + $items = $this->getStockItems($product->getCode()); |
|
87 | + $this->delete($product); |
|
88 | 88 | |
89 | 89 | |
90 | - $this->assertEquals( 2, count( $items ) ); |
|
90 | + $this->assertEquals(2, count($items)); |
|
91 | 91 | |
92 | - foreach( $items as $item ) { |
|
93 | - $this->assertEquals( 200, $item->getStocklevel() ); |
|
92 | + foreach ($items as $item) { |
|
93 | + $this->assertEquals(200, $item->getStocklevel()); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
@@ -109,21 +109,21 @@ discard block |
||
109 | 109 | 0 => '20', |
110 | 110 | ); |
111 | 111 | |
112 | - $product = $this->create( 'job_csv_test' ); |
|
112 | + $product = $this->create('job_csv_test'); |
|
113 | 113 | |
114 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard( $this->context, $mapping, $this->endpoint ); |
|
114 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard($this->context, $mapping, $this->endpoint); |
|
115 | 115 | |
116 | - $object->process( $product, $data ); |
|
117 | - $object->process( $product, $dataUpdate ); |
|
116 | + $object->process($product, $data); |
|
117 | + $object->process($product, $dataUpdate); |
|
118 | 118 | |
119 | - $items = $this->getStockItems( $product->getCode() ); |
|
120 | - $this->delete( $product ); |
|
119 | + $items = $this->getStockItems($product->getCode()); |
|
120 | + $this->delete($product); |
|
121 | 121 | |
122 | 122 | |
123 | - $item = reset( $items ); |
|
123 | + $item = reset($items); |
|
124 | 124 | |
125 | - $this->assertEquals( 1, count( $items ) ); |
|
126 | - $this->assertEquals( 20, $item->getStocklevel() ); |
|
125 | + $this->assertEquals(1, count($items)); |
|
126 | + $this->assertEquals(20, $item->getStocklevel()); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
@@ -137,19 +137,19 @@ discard block |
||
137 | 137 | 0 => 50, |
138 | 138 | ); |
139 | 139 | |
140 | - $product = $this->create( 'job_csv_test' ); |
|
140 | + $product = $this->create('job_csv_test'); |
|
141 | 141 | |
142 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard( $this->context, $mapping, $this->endpoint ); |
|
143 | - $object->process( $product, $data ); |
|
142 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard($this->context, $mapping, $this->endpoint); |
|
143 | + $object->process($product, $data); |
|
144 | 144 | |
145 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard( $this->context, [], $this->endpoint ); |
|
146 | - $object->process( $product, [] ); |
|
145 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard($this->context, [], $this->endpoint); |
|
146 | + $object->process($product, []); |
|
147 | 147 | |
148 | - $items = $this->getStockItems( $product->getCode() ); |
|
149 | - $this->delete( $product ); |
|
148 | + $items = $this->getStockItems($product->getCode()); |
|
149 | + $this->delete($product); |
|
150 | 150 | |
151 | 151 | |
152 | - $this->assertEquals( 0, count( $items ) ); |
|
152 | + $this->assertEquals(0, count($items)); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | |
@@ -167,20 +167,20 @@ discard block |
||
167 | 167 | 2 => '', |
168 | 168 | ); |
169 | 169 | |
170 | - $product = $this->create( 'job_csv_test' ); |
|
170 | + $product = $this->create('job_csv_test'); |
|
171 | 171 | |
172 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard( $this->context, $mapping, $this->endpoint ); |
|
173 | - $object->process( $product, $data ); |
|
172 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard($this->context, $mapping, $this->endpoint); |
|
173 | + $object->process($product, $data); |
|
174 | 174 | |
175 | - $items = $this->getStockItems( $product->getCode() ); |
|
176 | - $this->delete( $product ); |
|
175 | + $items = $this->getStockItems($product->getCode()); |
|
176 | + $this->delete($product); |
|
177 | 177 | |
178 | - $this->assertEquals( 1, count( $items ) ); |
|
178 | + $this->assertEquals(1, count($items)); |
|
179 | 179 | |
180 | - foreach( $items as $item ) |
|
180 | + foreach ($items as $item) |
|
181 | 181 | { |
182 | - $this->assertEquals( null, $item->getStocklevel() ); |
|
183 | - $this->assertEquals( null, $item->getDateBack() ); |
|
182 | + $this->assertEquals(null, $item->getStocklevel()); |
|
183 | + $this->assertEquals(null, $item->getDateBack()); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
@@ -188,43 +188,43 @@ discard block |
||
188 | 188 | /** |
189 | 189 | * @param string $code |
190 | 190 | */ |
191 | - protected function create( $code ) |
|
191 | + protected function create($code) |
|
192 | 192 | { |
193 | - $manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context ); |
|
194 | - $typeManager = $manager->getSubManager( 'type' ); |
|
193 | + $manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context); |
|
194 | + $typeManager = $manager->getSubManager('type'); |
|
195 | 195 | |
196 | 196 | $typeSearch = $typeManager->createSearch(); |
197 | - $typeSearch->setConditions( $typeSearch->compare( '==', 'product.type.code', 'default' ) ); |
|
198 | - $typeResult = $typeManager->searchItems( $typeSearch ); |
|
197 | + $typeSearch->setConditions($typeSearch->compare('==', 'product.type.code', 'default')); |
|
198 | + $typeResult = $typeManager->searchItems($typeSearch); |
|
199 | 199 | |
200 | - if( ( $typeItem = reset( $typeResult ) ) === false ) { |
|
201 | - throw new \RuntimeException( 'No product type "default" found' ); |
|
200 | + if (($typeItem = reset($typeResult)) === false) { |
|
201 | + throw new \RuntimeException('No product type "default" found'); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | $item = $manager->createItem(); |
205 | - $item->setTypeid( $typeItem->getId() ); |
|
206 | - $item->setCode( $code ); |
|
205 | + $item->setTypeid($typeItem->getId()); |
|
206 | + $item->setCode($code); |
|
207 | 207 | |
208 | - $manager->saveItem( $item ); |
|
208 | + $manager->saveItem($item); |
|
209 | 209 | |
210 | 210 | return $item; |
211 | 211 | } |
212 | 212 | |
213 | 213 | |
214 | - protected function delete( \Aimeos\MShop\Product\Item\Iface $product ) |
|
214 | + protected function delete(\Aimeos\MShop\Product\Item\Iface $product) |
|
215 | 215 | { |
216 | - $manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context ); |
|
217 | - $manager->deleteItem( $product->getId() ); |
|
216 | + $manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context); |
|
217 | + $manager->deleteItem($product->getId()); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | |
221 | - protected function getStockItems( $code ) |
|
221 | + protected function getStockItems($code) |
|
222 | 222 | { |
223 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'stock' ); |
|
223 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'stock'); |
|
224 | 224 | |
225 | 225 | $search = $manager->createSearch(); |
226 | - $search->setConditions( $search->compare( '==', 'stock.productcode', $code ) ); |
|
226 | + $search->setConditions($search->compare('==', 'stock.productcode', $code)); |
|
227 | 227 | |
228 | - return $manager->searchItems( $search ); |
|
228 | + return $manager->searchItems($search); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | \ No newline at end of file |
@@ -14,92 +14,92 @@ discard block |
||
14 | 14 | |
15 | 15 | protected function setUp() |
16 | 16 | { |
17 | - \Aimeos\MShop\Factory::setCache( true ); |
|
17 | + \Aimeos\MShop\Factory::setCache(true); |
|
18 | 18 | |
19 | 19 | $context = \TestHelperCntl::getContext(); |
20 | 20 | $aimeos = \TestHelperCntl::getAimeos(); |
21 | 21 | |
22 | - $this->object = new TestAbstract( $context, $aimeos ); |
|
22 | + $this->object = new TestAbstract($context, $aimeos); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | |
26 | 26 | protected function tearDown() |
27 | 27 | { |
28 | - \Aimeos\MShop\Factory::setCache( false ); |
|
28 | + \Aimeos\MShop\Factory::setCache(false); |
|
29 | 29 | \Aimeos\MShop\Factory::clear(); |
30 | 30 | } |
31 | 31 | |
32 | 32 | |
33 | 33 | public function testGetCache() |
34 | 34 | { |
35 | - $cache = $this->object->getCachePublic( 'attribute' ); |
|
35 | + $cache = $this->object->getCachePublic('attribute'); |
|
36 | 36 | |
37 | - $this->assertInstanceOf( '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\Iface', $cache ); |
|
37 | + $this->assertInstanceOf('\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\Iface', $cache); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
41 | 41 | public function testGetCacheInvalidType() |
42 | 42 | { |
43 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
44 | - $this->object->getCachePublic( '$' ); |
|
43 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
44 | + $this->object->getCachePublic('$'); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | |
48 | 48 | public function testGetCacheInvalidClass() |
49 | 49 | { |
50 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
51 | - $this->object->getCachePublic( 'unknown' ); |
|
50 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
51 | + $this->object->getCachePublic('unknown'); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
55 | 55 | public function testGetCacheInvalidInterface() |
56 | 56 | { |
57 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
58 | - $this->object->getCachePublic( 'attribute', 'unknown' ); |
|
57 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
58 | + $this->object->getCachePublic('attribute', 'unknown'); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
62 | 62 | public function testGetProcessors() |
63 | 63 | { |
64 | - $processor = $this->object->getProcessorsPublic( array( 'attribute' => [] ) ); |
|
64 | + $processor = $this->object->getProcessorsPublic(array('attribute' => [])); |
|
65 | 65 | |
66 | - $this->assertInstanceOf( '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\Iface', $processor ); |
|
66 | + $this->assertInstanceOf('\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\Iface', $processor); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
70 | 70 | public function testGetProcessorsInvalidType() |
71 | 71 | { |
72 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
73 | - $this->object->getProcessorsPublic( array( '$' => [] ) ); |
|
72 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
73 | + $this->object->getProcessorsPublic(array('$' => [])); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | |
77 | 77 | public function testGetProcessorsInvalidClass() |
78 | 78 | { |
79 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
80 | - $this->object->getProcessorsPublic( array( 'unknown' => [] ) ); |
|
79 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
80 | + $this->object->getProcessorsPublic(array('unknown' => [])); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
84 | 84 | public function testGetProcessorsInvalidInterface() |
85 | 85 | { |
86 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
87 | - $this->object->getProcessorsPublic( array( 'unknown' => [] ) ); |
|
86 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
87 | + $this->object->getProcessorsPublic(array('unknown' => [])); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | |
91 | 91 | public function testGetTypeId() |
92 | 92 | { |
93 | - $typeid = $this->object->getTypeIdPublic( 'attribute/type', 'product', 'color' ); |
|
93 | + $typeid = $this->object->getTypeIdPublic('attribute/type', 'product', 'color'); |
|
94 | 94 | |
95 | - $this->assertNotEquals( null, $typeid ); |
|
95 | + $this->assertNotEquals(null, $typeid); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
99 | 99 | public function testGetTypeIdUnknown() |
100 | 100 | { |
101 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
102 | - $this->object->getTypeIdPublic( 'attribute/type', 'product', 'unknown' ); |
|
101 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
102 | + $this->object->getTypeIdPublic('attribute/type', 'product', 'unknown'); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
@@ -107,21 +107,21 @@ discard block |
||
107 | 107 | class TestAbstract |
108 | 108 | extends \Aimeos\Controller\Common\Product\Import\Csv\Base |
109 | 109 | { |
110 | - public function getCachePublic( $type, $name = null ) |
|
110 | + public function getCachePublic($type, $name = null) |
|
111 | 111 | { |
112 | - return $this->getCache( $type, $name ); |
|
112 | + return $this->getCache($type, $name); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | |
116 | - public function getProcessorsPublic( array $mappings ) |
|
116 | + public function getProcessorsPublic(array $mappings) |
|
117 | 117 | { |
118 | - return $this->getProcessors( $mappings ); |
|
118 | + return $this->getProcessors($mappings); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | |
122 | - public function getTypeIdPublic( $path, $domain, $code ) |
|
122 | + public function getTypeIdPublic($path, $domain, $code) |
|
123 | 123 | { |
124 | - return $this->getTypeId( $path, $domain, $code ); |
|
124 | + return $this->getTypeId($path, $domain, $code); |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 |
@@ -40,15 +40,15 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
42 | 42 | */ |
43 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
|
43 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context) |
|
44 | 44 | { |
45 | - parent::__construct( $context ); |
|
45 | + parent::__construct($context); |
|
46 | 46 | |
47 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'attribute' ); |
|
48 | - $result = $manager->searchItems( $manager->createSearch() ); |
|
47 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'attribute'); |
|
48 | + $result = $manager->searchItems($manager->createSearch()); |
|
49 | 49 | |
50 | - foreach( $result as $id => $item ) { |
|
51 | - $this->attributes[ $item->getCode() ][ $item->getType() ] = $item; |
|
50 | + foreach ($result as $id => $item) { |
|
51 | + $this->attributes[$item->getCode()][$item->getType()] = $item; |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
@@ -60,24 +60,24 @@ discard block |
||
60 | 60 | * @param string|null $type Attribute type |
61 | 61 | * @return \Aimeos\MShop\Attribute\Item\Iface|null Attribute object or null if not found |
62 | 62 | */ |
63 | - public function get( $code, $type = null ) |
|
63 | + public function get($code, $type = null) |
|
64 | 64 | { |
65 | - if( isset( $this->attributes[$code] ) && isset( $this->attributes[$code][$type] ) ) { |
|
65 | + if (isset($this->attributes[$code]) && isset($this->attributes[$code][$type])) { |
|
66 | 66 | return $this->attributes[$code][$type]; |
67 | 67 | } |
68 | 68 | |
69 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
69 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
70 | 70 | |
71 | 71 | $search = $manager->createSearch(); |
72 | 72 | $expr = array( |
73 | - $search->compare( '==', 'attribute.code', $code ), |
|
74 | - $search->compare( '==', 'attribute.type.code', $type ), |
|
73 | + $search->compare('==', 'attribute.code', $code), |
|
74 | + $search->compare('==', 'attribute.type.code', $type), |
|
75 | 75 | ); |
76 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
76 | + $search->setConditions($search->combine('&&', $expr)); |
|
77 | 77 | |
78 | - $result = $manager->searchItems( $search ); |
|
78 | + $result = $manager->searchItems($search); |
|
79 | 79 | |
80 | - if( ( $item = reset( $result ) ) !== false ) |
|
80 | + if (($item = reset($result)) !== false) |
|
81 | 81 | { |
82 | 82 | $this->attributes[$code][$type] = $item; |
83 | 83 | return $item; |
@@ -90,14 +90,14 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @param \Aimeos\MShop\Common\Item\Iface $item Attribute object |
92 | 92 | */ |
93 | - public function set( \Aimeos\MShop\Common\Item\Iface $item ) |
|
93 | + public function set(\Aimeos\MShop\Common\Item\Iface $item) |
|
94 | 94 | { |
95 | 95 | $code = $item->getCode(); |
96 | 96 | |
97 | - if( !isset( $this->attributes[$code] ) || !is_array( $this->attributes[$code] ) ) { |
|
97 | + if (!isset($this->attributes[$code]) || !is_array($this->attributes[$code])) { |
|
98 | 98 | $this->attributes[$code] = []; |
99 | 99 | } |
100 | 100 | |
101 | - $this->attributes[$code][ $item->getType() ] = $item; |
|
101 | + $this->attributes[$code][$item->getType()] = $item; |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | \ No newline at end of file |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | * @param array $data Associative list of product codes and lists of CSV field indexes and their data |
31 | 31 | * @return array Associative list of CSV field indexes and their converted data |
32 | 32 | */ |
33 | - protected function convertData( array $convlist, array $data ) |
|
33 | + protected function convertData(array $convlist, array $data) |
|
34 | 34 | { |
35 | - foreach( $convlist as $idx => $converter ) |
|
35 | + foreach ($convlist as $idx => $converter) |
|
36 | 36 | { |
37 | - foreach( $data as $code => $list ) |
|
37 | + foreach ($data as $code => $list) |
|
38 | 38 | { |
39 | - if( isset( $list[$idx] ) ) { |
|
40 | - $data[$code][$idx] = $converter->translate( $list[$idx] ); |
|
39 | + if (isset($list[$idx])) { |
|
40 | + $data[$code][$idx] = $converter->translate($list[$idx]); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
@@ -53,38 +53,38 @@ discard block |
||
53 | 53 | * @param string|null Name of the cache implementation |
54 | 54 | * @return \Aimeos\Controller\Common\Product\Import\Csv\Cache\Iface Cache object |
55 | 55 | */ |
56 | - protected function getCache( $type, $name = null ) |
|
56 | + protected function getCache($type, $name = null) |
|
57 | 57 | { |
58 | 58 | $context = $this->getContext(); |
59 | 59 | $config = $context->getConfig(); |
60 | 60 | $iface = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\Iface'; |
61 | 61 | |
62 | - if( ctype_alnum( $type ) === false ) |
|
62 | + if (ctype_alnum($type) === false) |
|
63 | 63 | { |
64 | 64 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . $type : '<not a string>'; |
65 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
65 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
66 | 66 | } |
67 | 67 | |
68 | - if( $name === null ) { |
|
69 | - $name = $config->get( 'controller/common/product/import/csv/cache/' . $type . '/name', 'Standard' ); |
|
68 | + if ($name === null) { |
|
69 | + $name = $config->get('controller/common/product/import/csv/cache/' . $type . '/name', 'Standard'); |
|
70 | 70 | } |
71 | 71 | |
72 | - if( ctype_alnum( $name ) === false ) |
|
72 | + if (ctype_alnum($name) === false) |
|
73 | 73 | { |
74 | 74 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . $type . '\\' . $name : '<not a string>'; |
75 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
75 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
76 | 76 | } |
77 | 77 | |
78 | - $classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . ucfirst( $type ) . '\\' . $name; |
|
78 | + $classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . ucfirst($type) . '\\' . $name; |
|
79 | 79 | |
80 | - if( class_exists( $classname ) === false ) { |
|
81 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) ); |
|
80 | + if (class_exists($classname) === false) { |
|
81 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname)); |
|
82 | 82 | } |
83 | 83 | |
84 | - $object = new $classname( $context ); |
|
84 | + $object = new $classname($context); |
|
85 | 85 | |
86 | - if( !( $object instanceof $iface ) ) { |
|
87 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" does not implement interface "%2$s"', $classname, $iface ) ); |
|
86 | + if (!($object instanceof $iface)) { |
|
87 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" does not implement interface "%2$s"', $classname, $iface)); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | return $object; |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | * @param array $convmap List of converter names for the values at the position in the CSV file |
98 | 98 | * @return array Associative list of positions and converter objects |
99 | 99 | */ |
100 | - protected function getConverterList( array $convmap ) |
|
100 | + protected function getConverterList(array $convmap) |
|
101 | 101 | { |
102 | 102 | $convlist = []; |
103 | 103 | |
104 | - foreach( $convmap as $idx => $name ) { |
|
105 | - $convlist[$idx] = \Aimeos\MW\Convert\Factory::createConverter( $name ); |
|
104 | + foreach ($convmap as $idx => $name) { |
|
105 | + $convlist[$idx] = \Aimeos\MW\Convert\Factory::createConverter($name); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | return $convlist; |
@@ -117,15 +117,15 @@ discard block |
||
117 | 117 | * @param integer $codePos Column position which contains the unique product code (starting from 0) |
118 | 118 | * @return array List of arrays with product codes as keys and list of values from the CSV file |
119 | 119 | */ |
120 | - protected function getData( \Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos ) |
|
120 | + protected function getData(\Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos) |
|
121 | 121 | { |
122 | 122 | $count = 0; |
123 | 123 | $data = []; |
124 | 124 | |
125 | - while( $content->valid() && $count++ < $maxcnt ) |
|
125 | + while ($content->valid() && $count++ < $maxcnt) |
|
126 | 126 | { |
127 | 127 | $row = $content->current(); |
128 | - $data[ $row[$codePos] ] = $row; |
|
128 | + $data[$row[$codePos]] = $row; |
|
129 | 129 | $content->next(); |
130 | 130 | } |
131 | 131 | |
@@ -222,21 +222,21 @@ discard block |
||
222 | 222 | * @param array $mapping List of domain item keys with the CSV field position as key |
223 | 223 | * @return array List of associative arrays containing the chunked properties |
224 | 224 | */ |
225 | - protected function getMappedChunk( array &$data, array $mapping ) |
|
225 | + protected function getMappedChunk(array &$data, array $mapping) |
|
226 | 226 | { |
227 | 227 | $idx = 0; |
228 | 228 | $map = []; |
229 | 229 | |
230 | - foreach( $mapping as $pos => $key ) |
|
230 | + foreach ($mapping as $pos => $key) |
|
231 | 231 | { |
232 | - if( isset( $map[$idx][$key] ) ) { |
|
232 | + if (isset($map[$idx][$key])) { |
|
233 | 233 | $idx++; |
234 | 234 | } |
235 | 235 | |
236 | - if( isset( $data[$pos] ) ) |
|
236 | + if (isset($data[$pos])) |
|
237 | 237 | { |
238 | 238 | $map[$idx][$key] = $data[$pos]; |
239 | - unset( $data[$pos] ); |
|
239 | + unset($data[$pos]); |
|
240 | 240 | } |
241 | 241 | } |
242 | 242 | |
@@ -250,39 +250,39 @@ discard block |
||
250 | 250 | * @param array $mappings Associative list of processor types as keys and index/data mappings as values |
251 | 251 | * @return \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface Processor object |
252 | 252 | */ |
253 | - protected function getProcessors( array $mappings ) |
|
253 | + protected function getProcessors(array $mappings) |
|
254 | 254 | { |
255 | 255 | $context = $this->getContext(); |
256 | 256 | $config = $context->getConfig(); |
257 | 257 | $iface = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\Iface'; |
258 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done( $context, [] ); |
|
258 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done($context, []); |
|
259 | 259 | |
260 | - foreach( $mappings as $type => $mapping ) |
|
260 | + foreach ($mappings as $type => $mapping) |
|
261 | 261 | { |
262 | - if( ctype_alnum( $type ) === false ) |
|
262 | + if (ctype_alnum($type) === false) |
|
263 | 263 | { |
264 | 264 | $classname = is_string($type) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . $type : '<not a string>'; |
265 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
265 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
266 | 266 | } |
267 | 267 | |
268 | - $name = $config->get( 'controller/common/product/import/csv/processor/' . $type . '/name', 'Standard' ); |
|
268 | + $name = $config->get('controller/common/product/import/csv/processor/' . $type . '/name', 'Standard'); |
|
269 | 269 | |
270 | - if( ctype_alnum( $name ) === false ) |
|
270 | + if (ctype_alnum($name) === false) |
|
271 | 271 | { |
272 | 272 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . $type . '\\' . $name : '<not a string>'; |
273 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
273 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
274 | 274 | } |
275 | 275 | |
276 | - $classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . ucfirst( $type ) . '\\' . $name; |
|
276 | + $classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . ucfirst($type) . '\\' . $name; |
|
277 | 277 | |
278 | - if( class_exists( $classname ) === false ) { |
|
279 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) ); |
|
278 | + if (class_exists($classname) === false) { |
|
279 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname)); |
|
280 | 280 | } |
281 | 281 | |
282 | - $object = new $classname( $context, $mapping, $object ); |
|
282 | + $object = new $classname($context, $mapping, $object); |
|
283 | 283 | |
284 | - if( !( $object instanceof $iface ) ) { |
|
285 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" does not implement interface "%2$s"', $classname, $iface ) ); |
|
284 | + if (!($object instanceof $iface)) { |
|
285 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" does not implement interface "%2$s"', $classname, $iface)); |
|
286 | 286 | } |
287 | 287 | } |
288 | 288 | |
@@ -297,17 +297,17 @@ discard block |
||
297 | 297 | * @param array $domains List of domains whose items should be fetched too |
298 | 298 | * @return array Associative list of product codes as key and product items as value |
299 | 299 | */ |
300 | - protected function getProducts( array $codes, array $domains ) |
|
300 | + protected function getProducts(array $codes, array $domains) |
|
301 | 301 | { |
302 | 302 | $result = []; |
303 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
303 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
304 | 304 | |
305 | 305 | $search = $manager->createSearch(); |
306 | - $search->setConditions( $search->compare( '==', 'product.code', $codes ) ); |
|
307 | - $search->setSlice( 0, count( $codes ) ); |
|
306 | + $search->setConditions($search->compare('==', 'product.code', $codes)); |
|
307 | + $search->setSlice(0, count($codes)); |
|
308 | 308 | |
309 | - foreach( $manager->searchItems( $search, $domains ) as $item ) { |
|
310 | - $result[ $item->getCode() ] = $item; |
|
309 | + foreach ($manager->searchItems($search, $domains) as $item) { |
|
310 | + $result[$item->getCode()] = $item; |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | return $result; |
@@ -322,23 +322,23 @@ discard block |
||
322 | 322 | * @param string $code Unique code of the type item |
323 | 323 | * @return string Unique ID of the type item |
324 | 324 | */ |
325 | - protected function getTypeId( $path, $domain, $code ) |
|
325 | + protected function getTypeId($path, $domain, $code) |
|
326 | 326 | { |
327 | - if( !isset( self::$types[$path][$domain] ) ) |
|
327 | + if (!isset(self::$types[$path][$domain])) |
|
328 | 328 | { |
329 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $path ); |
|
330 | - $key = str_replace( '/', '.', $path ); |
|
329 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $path); |
|
330 | + $key = str_replace('/', '.', $path); |
|
331 | 331 | |
332 | 332 | $search = $manager->createSearch(); |
333 | - $search->setConditions( $search->compare( '==', $key . '.domain', $domain ) ); |
|
333 | + $search->setConditions($search->compare('==', $key . '.domain', $domain)); |
|
334 | 334 | |
335 | - foreach( $manager->searchItems( $search ) as $id => $item ) { |
|
336 | - self::$types[$path][$domain][ $item->getCode() ] = $id; |
|
335 | + foreach ($manager->searchItems($search) as $id => $item) { |
|
336 | + self::$types[$path][$domain][$item->getCode()] = $id; |
|
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
340 | - if( !isset( self::$types[$path][$domain][$code] ) ) { |
|
341 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No type item for "%1$s/%2$s" in "%3$s" found', $domain, $code, $path ) ); |
|
340 | + if (!isset(self::$types[$path][$domain][$code])) { |
|
341 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('No type item for "%1$s/%2$s" in "%3$s" found', $domain, $code, $path)); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | return self::$types[$path][$domain][$code]; |
@@ -40,52 +40,52 @@ discard block |
||
40 | 40 | * @param array $data List of CSV fields with position as key and data as value |
41 | 41 | * @return array List of data which hasn't been imported |
42 | 42 | */ |
43 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
43 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
44 | 44 | { |
45 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/property' ); |
|
45 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/property'); |
|
46 | 46 | $manager->begin(); |
47 | 47 | |
48 | 48 | try |
49 | 49 | { |
50 | 50 | $propMap = []; |
51 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
52 | - $items = $this->getPropertyItems( $product->getId() ); |
|
51 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
52 | + $items = $this->getPropertyItems($product->getId()); |
|
53 | 53 | |
54 | - foreach( $items as $item ) { |
|
55 | - $propMap[ $item->getValue() ][ $item->getType() ] = $item; |
|
54 | + foreach ($items as $item) { |
|
55 | + $propMap[$item->getValue()][$item->getType()] = $item; |
|
56 | 56 | } |
57 | 57 | |
58 | - foreach( $map as $list ) |
|
58 | + foreach ($map as $list) |
|
59 | 59 | { |
60 | - if( $list['product.property.type'] == '' || $list['product.property.value'] == '' ) { |
|
60 | + if ($list['product.property.type'] == '' || $list['product.property.value'] == '') { |
|
61 | 61 | continue; |
62 | 62 | } |
63 | 63 | |
64 | 64 | $typecode = $list['product.property.type']; |
65 | - $list['product.property.typeid'] = $this->getTypeId( 'product/property/type', 'product', $typecode ); |
|
65 | + $list['product.property.typeid'] = $this->getTypeId('product/property/type', 'product', $typecode); |
|
66 | 66 | $list['product.property.parentid'] = $product->getId(); |
67 | 67 | |
68 | - if( isset( $propMap[ $list['product.property.value'] ][$typecode] ) ) |
|
68 | + if (isset($propMap[$list['product.property.value']][$typecode])) |
|
69 | 69 | { |
70 | - $item = $propMap[ $list['product.property.value'] ][$typecode]; |
|
71 | - unset( $items[ $item->getId() ] ); |
|
70 | + $item = $propMap[$list['product.property.value']][$typecode]; |
|
71 | + unset($items[$item->getId()]); |
|
72 | 72 | } |
73 | 73 | else |
74 | 74 | { |
75 | 75 | $item = $manager->createItem(); |
76 | 76 | } |
77 | 77 | |
78 | - $item->fromArray( $list ); |
|
79 | - $manager->saveItem( $item ); |
|
78 | + $item->fromArray($list); |
|
79 | + $manager->saveItem($item); |
|
80 | 80 | } |
81 | 81 | |
82 | - $manager->deleteItems( array_keys( $items ) ); |
|
82 | + $manager->deleteItems(array_keys($items)); |
|
83 | 83 | |
84 | - $data = $this->getObject()->process( $product, $data ); |
|
84 | + $data = $this->getObject()->process($product, $data); |
|
85 | 85 | |
86 | 86 | $manager->commit(); |
87 | 87 | } |
88 | - catch( \Exception $e ) |
|
88 | + catch (\Exception $e) |
|
89 | 89 | { |
90 | 90 | $manager->rollback(); |
91 | 91 | throw $e; |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | * @param string $prodid Unique product ID |
102 | 102 | * @return array Associative list of product property items |
103 | 103 | */ |
104 | - protected function getPropertyItems( $prodid ) |
|
104 | + protected function getPropertyItems($prodid) |
|
105 | 105 | { |
106 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/property' ); |
|
106 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/property'); |
|
107 | 107 | |
108 | 108 | $search = $manager->createSearch(); |
109 | - $search->setConditions( $search->compare( '==', 'product.property.parentid', $prodid ) ); |
|
109 | + $search->setConditions($search->compare('==', 'product.property.parentid', $prodid)); |
|
110 | 110 | |
111 | - return $manager->searchItems( $search ); |
|
111 | + return $manager->searchItems($search); |
|
112 | 112 | } |
113 | 113 | } |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
44 | 44 | * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor |
45 | 45 | */ |
46 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
47 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null ) |
|
46 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
47 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null) |
|
48 | 48 | { |
49 | - parent::__construct( $context, $mapping, $object ); |
|
49 | + parent::__construct($context, $mapping, $object); |
|
50 | 50 | |
51 | 51 | /** controller/common/product/import/csv/processor/catalog/listtypes |
52 | 52 | * Names of the catalog list types that are updated or removed |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | * @see controller/common/product/import/csv/processor/product/listtypes |
68 | 68 | * @see controller/common/product/import/csv/processor/text/listtypes |
69 | 69 | */ |
70 | - $this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/catalog/listtypes' ); |
|
70 | + $this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/catalog/listtypes'); |
|
71 | 71 | |
72 | - $this->cache = $this->getCache( 'catalog' ); |
|
72 | + $this->cache = $this->getCache('catalog'); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | * @param array $data List of CSV fields with position as key and data as value |
81 | 81 | * @return array List of data which hasn't been imported |
82 | 82 | */ |
83 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
83 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
84 | 84 | { |
85 | 85 | $context = $this->getContext(); |
86 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'catalog' ); |
|
87 | - $listManager = \Aimeos\MShop\Factory::createManager( $context, 'catalog/lists' ); |
|
86 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'catalog'); |
|
87 | + $listManager = \Aimeos\MShop\Factory::createManager($context, 'catalog/lists'); |
|
88 | 88 | |
89 | 89 | /** controller/common/product/import/csv/separator |
90 | 90 | * Single separator character for multiple entries in one field of the import file |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @category Developer |
105 | 105 | * @see controller/common/product/import/csv/domains |
106 | 106 | */ |
107 | - $separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" ); |
|
107 | + $separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n"); |
|
108 | 108 | |
109 | 109 | $manager->begin(); |
110 | 110 | |
@@ -112,56 +112,56 @@ discard block |
||
112 | 112 | { |
113 | 113 | $listMap = []; |
114 | 114 | $prodid = $product->getId(); |
115 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
116 | - $listItems = $this->getListItems( $prodid, $this->listTypes ); |
|
115 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
116 | + $listItems = $this->getListItems($prodid, $this->listTypes); |
|
117 | 117 | |
118 | - foreach( $listItems as $listItem ) { |
|
119 | - $listMap[ $listItem->getParentId() ][ $listItem->getType() ] = $listItem; |
|
118 | + foreach ($listItems as $listItem) { |
|
119 | + $listMap[$listItem->getParentId()][$listItem->getType()] = $listItem; |
|
120 | 120 | } |
121 | 121 | |
122 | - foreach( $map as $pos => $list ) |
|
122 | + foreach ($map as $pos => $list) |
|
123 | 123 | { |
124 | - if( $this->checkEntry( $list ) === false ) { |
|
124 | + if ($this->checkEntry($list) === false) { |
|
125 | 125 | continue; |
126 | 126 | } |
127 | 127 | |
128 | - $codes = explode( $separator, $list['catalog.code'] ); |
|
129 | - $type = ( isset( $list['catalog.lists.type'] ) ? $list['catalog.lists.type'] : 'default' ); |
|
128 | + $codes = explode($separator, $list['catalog.code']); |
|
129 | + $type = (isset($list['catalog.lists.type']) ? $list['catalog.lists.type'] : 'default'); |
|
130 | 130 | |
131 | - foreach( $codes as $code ) |
|
131 | + foreach ($codes as $code) |
|
132 | 132 | { |
133 | - if( ( $catid = $this->cache->get( $code ) ) === null ) |
|
133 | + if (($catid = $this->cache->get($code)) === null) |
|
134 | 134 | { |
135 | 135 | $msg = 'No category for code "%1$s" available when importing product with code "%2$s"'; |
136 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( $msg, $code, $product->getCode() ) ); |
|
136 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf($msg, $code, $product->getCode())); |
|
137 | 137 | } |
138 | 138 | |
139 | - $list['catalog.lists.typeid'] = $this->getTypeId( 'catalog/lists/type', 'product', $type ); |
|
139 | + $list['catalog.lists.typeid'] = $this->getTypeId('catalog/lists/type', 'product', $type); |
|
140 | 140 | $list['catalog.lists.parentid'] = $catid; |
141 | 141 | $list['catalog.lists.refid'] = $prodid; |
142 | 142 | $list['catalog.lists.domain'] = 'product'; |
143 | 143 | |
144 | - if( isset( $listMap[$catid][$type] ) ) |
|
144 | + if (isset($listMap[$catid][$type])) |
|
145 | 145 | { |
146 | 146 | $listItem = $listMap[$catid][$type]; |
147 | - unset( $listItems[ $listItem->getId() ] ); |
|
147 | + unset($listItems[$listItem->getId()]); |
|
148 | 148 | } |
149 | 149 | else |
150 | 150 | { |
151 | 151 | $listItem = $listManager->createItem(); |
152 | 152 | } |
153 | 153 | |
154 | - $listItem->fromArray( $this->addListItemDefaults( $list, $pos++ ) ); |
|
155 | - $listManager->saveItem( $listItem ); |
|
154 | + $listItem->fromArray($this->addListItemDefaults($list, $pos++)); |
|
155 | + $listManager->saveItem($listItem); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | |
159 | - $listManager->deleteItems( array_keys( $listItems ) ); |
|
160 | - $data = $this->getObject()->process( $product, $data ); |
|
159 | + $listManager->deleteItems(array_keys($listItems)); |
|
160 | + $data = $this->getObject()->process($product, $data); |
|
161 | 161 | |
162 | 162 | $manager->commit(); |
163 | 163 | } |
164 | - catch( \Exception $e ) |
|
164 | + catch (\Exception $e) |
|
165 | 165 | { |
166 | 166 | $manager->rollback(); |
167 | 167 | throw $e; |
@@ -178,13 +178,13 @@ discard block |
||
178 | 178 | * @param integer $pos Computed position of the list item in the associated list of items |
179 | 179 | * @return array Given associative list enriched by default values if they were not already set |
180 | 180 | */ |
181 | - protected function addListItemDefaults( array $list, $pos ) |
|
181 | + protected function addListItemDefaults(array $list, $pos) |
|
182 | 182 | { |
183 | - if( !isset( $list['catalog.lists.position'] ) ) { |
|
183 | + if (!isset($list['catalog.lists.position'])) { |
|
184 | 184 | $list['catalog.lists.position'] = $pos; |
185 | 185 | } |
186 | 186 | |
187 | - if( !isset( $list['catalog.lists.status'] ) ) { |
|
187 | + if (!isset($list['catalog.lists.status'])) { |
|
188 | 188 | $list['catalog.lists.status'] = 1; |
189 | 189 | } |
190 | 190 | |
@@ -198,10 +198,10 @@ discard block |
||
198 | 198 | * @param array $list Associative list of key/value pairs from the mapped data |
199 | 199 | * @return boolean True if the entry is valid, false if not |
200 | 200 | */ |
201 | - protected function checkEntry( array $list ) |
|
201 | + protected function checkEntry(array $list) |
|
202 | 202 | { |
203 | - if( !isset( $list['catalog.code'] ) || $list['catalog.code'] === '' || isset( $list['catalog.lists.type'] ) |
|
204 | - && $this->listTypes !== null && !in_array( $list['catalog.lists.type'], (array) $this->listTypes ) |
|
203 | + if (!isset($list['catalog.code']) || $list['catalog.code'] === '' || isset($list['catalog.lists.type']) |
|
204 | + && $this->listTypes !== null && !in_array($list['catalog.lists.type'], (array) $this->listTypes) |
|
205 | 205 | ) { |
206 | 206 | return false; |
207 | 207 | } |
@@ -217,24 +217,24 @@ discard block |
||
217 | 217 | * @param array|null $types List of catalog list types |
218 | 218 | * @return array List of catalog list items |
219 | 219 | */ |
220 | - protected function getListItems( $prodid, $types ) |
|
220 | + protected function getListItems($prodid, $types) |
|
221 | 221 | { |
222 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' ); |
|
222 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists'); |
|
223 | 223 | $search = $manager->createSearch(); |
224 | 224 | |
225 | 225 | $expr = array( |
226 | - $search->compare( '==', 'catalog.lists.domain', 'product' ), |
|
227 | - $search->compare( '==', 'catalog.lists.refid', $prodid ), |
|
226 | + $search->compare('==', 'catalog.lists.domain', 'product'), |
|
227 | + $search->compare('==', 'catalog.lists.refid', $prodid), |
|
228 | 228 | ); |
229 | 229 | |
230 | - if( $types !== null ) { |
|
231 | - $expr[] = $search->compare( '==', 'catalog.lists.type.code', $types ); |
|
230 | + if ($types !== null) { |
|
231 | + $expr[] = $search->compare('==', 'catalog.lists.type.code', $types); |
|
232 | 232 | } |
233 | 233 | |
234 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
235 | - $search->setSortations( array( $search->sort( '+', 'catalog.lists.position' ) ) ); |
|
236 | - $search->setSlice( 0, 0x7FFFFFFF ); |
|
234 | + $search->setConditions($search->combine('&&', $expr)); |
|
235 | + $search->setSortations(array($search->sort('+', 'catalog.lists.position'))); |
|
236 | + $search->setSlice(0, 0x7FFFFFFF); |
|
237 | 237 | |
238 | - return $manager->searchItems( $search ); |
|
238 | + return $manager->searchItems($search); |
|
239 | 239 | } |
240 | 240 | } |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
44 | 44 | * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor |
45 | 45 | */ |
46 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
47 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null ) |
|
46 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
47 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null) |
|
48 | 48 | { |
49 | - parent::__construct( $context, $mapping, $object ); |
|
49 | + parent::__construct($context, $mapping, $object); |
|
50 | 50 | |
51 | 51 | /** controller/common/product/import/csv/processor/product/listtypes |
52 | 52 | * Names of the product list types that are updated or removed |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | * @see controller/common/product/import/csv/processor/price/listtypes |
74 | 74 | * @see controller/common/product/import/csv/processor/text/listtypes |
75 | 75 | */ |
76 | - $default = array( 'default', 'suggestion' ); |
|
76 | + $default = array('default', 'suggestion'); |
|
77 | 77 | $key = 'controller/common/product/import/csv/processor/product/listtypes'; |
78 | - $this->listTypes = $context->getConfig()->get( $key, $default ); |
|
78 | + $this->listTypes = $context->getConfig()->get($key, $default); |
|
79 | 79 | |
80 | - $this->cache = $this->getCache( 'product' ); |
|
80 | + $this->cache = $this->getCache('product'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -88,13 +88,13 @@ discard block |
||
88 | 88 | * @param array $data List of CSV fields with position as key and data as value |
89 | 89 | * @return array List of data which hasn't been imported |
90 | 90 | */ |
91 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
91 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
92 | 92 | { |
93 | 93 | $context = $this->getContext(); |
94 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
95 | - $separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" ); |
|
94 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
95 | + $separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n"); |
|
96 | 96 | |
97 | - $this->cache->set( $product ); |
|
97 | + $this->cache->set($product); |
|
98 | 98 | |
99 | 99 | $manager->begin(); |
100 | 100 | |
@@ -102,37 +102,37 @@ discard block |
||
102 | 102 | { |
103 | 103 | $types = []; |
104 | 104 | |
105 | - foreach( $this->getMappedChunk( $data, $this->getMapping() ) as $list ) |
|
105 | + foreach ($this->getMappedChunk($data, $this->getMapping()) as $list) |
|
106 | 106 | { |
107 | - if( $this->checkEntry( $list ) === false ) { |
|
107 | + if ($this->checkEntry($list) === false) { |
|
108 | 108 | continue; |
109 | 109 | } |
110 | 110 | |
111 | 111 | $listMap = []; |
112 | - $type = ( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' ); |
|
112 | + $type = (isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default'); |
|
113 | 113 | $types[] = $type; |
114 | 114 | |
115 | - foreach( explode( $separator, $list['product.code'] ) as $code ) |
|
115 | + foreach (explode($separator, $list['product.code']) as $code) |
|
116 | 116 | { |
117 | - if( ( $prodid = $this->cache->get( $code ) ) === null ) |
|
117 | + if (($prodid = $this->cache->get($code)) === null) |
|
118 | 118 | { |
119 | 119 | $msg = 'No product for code "%1$s" available when importing product with code "%2$s"'; |
120 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( $msg, $code, $product->getCode() ) ); |
|
120 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf($msg, $code, $product->getCode())); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | $listMap[$prodid] = $list; |
124 | 124 | } |
125 | 125 | |
126 | - $manager->updateListItems( $product, $listMap, 'product', $type ); |
|
126 | + $manager->updateListItems($product, $listMap, 'product', $type); |
|
127 | 127 | } |
128 | 128 | |
129 | - $this->deleteListItems( $product->getId(), $types ); |
|
129 | + $this->deleteListItems($product->getId(), $types); |
|
130 | 130 | |
131 | - $data = $this->getObject()->process( $product, $data ); |
|
131 | + $data = $this->getObject()->process($product, $data); |
|
132 | 132 | |
133 | 133 | $manager->commit(); |
134 | 134 | } |
135 | - catch( \Exception $e ) |
|
135 | + catch (\Exception $e) |
|
136 | 136 | { |
137 | 137 | $manager->rollback(); |
138 | 138 | throw $e; |
@@ -148,10 +148,10 @@ discard block |
||
148 | 148 | * @param array $list Associative list of key/value pairs from the mapping |
149 | 149 | * @return boolean True if valid, false if not |
150 | 150 | */ |
151 | - protected function checkEntry( array $list ) |
|
151 | + protected function checkEntry(array $list) |
|
152 | 152 | { |
153 | - if( !isset( $list['product.code'] ) || $list['product.code'] === '' || isset( $list['product.lists.type'] ) |
|
154 | - && $this->listTypes !== null && !in_array( $list['product.lists.type'], (array) $this->listTypes ) |
|
153 | + if (!isset($list['product.code']) || $list['product.code'] === '' || isset($list['product.lists.type']) |
|
154 | + && $this->listTypes !== null && !in_array($list['product.lists.type'], (array) $this->listTypes) |
|
155 | 155 | ) { |
156 | 156 | return false; |
157 | 157 | } |
@@ -166,19 +166,19 @@ discard block |
||
166 | 166 | * @param string $prodId Unique product ID |
167 | 167 | * @param array $types List of types that have been updated |
168 | 168 | */ |
169 | - protected function deleteListItems( $prodId, array $types ) |
|
169 | + protected function deleteListItems($prodId, array $types) |
|
170 | 170 | { |
171 | - $codes = array_diff( $this->listTypes, $types ); |
|
172 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' ); |
|
171 | + $codes = array_diff($this->listTypes, $types); |
|
172 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists'); |
|
173 | 173 | |
174 | 174 | $search = $manager->createSearch(); |
175 | 175 | $expr = array( |
176 | - $search->compare( '==', 'product.lists.parentid', $prodId ), |
|
177 | - $search->compare( '==', 'product.lists.domain', 'product' ), |
|
178 | - $search->compare( '==', 'product.lists.type.code', $codes ), |
|
176 | + $search->compare('==', 'product.lists.parentid', $prodId), |
|
177 | + $search->compare('==', 'product.lists.domain', 'product'), |
|
178 | + $search->compare('==', 'product.lists.type.code', $codes), |
|
179 | 179 | ); |
180 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
180 | + $search->setConditions($search->combine('&&', $expr)); |
|
181 | 181 | |
182 | - $manager->deleteItems( array_keys( $manager->searchItems( $search ) ) ); |
|
182 | + $manager->deleteItems(array_keys($manager->searchItems($search))); |
|
183 | 183 | } |
184 | 184 | } |