@@ -326,7 +326,7 @@ |
||
326 | 326 | * |
327 | 327 | * @param string $name One of "domain", "max-items" or "max-query" |
328 | 328 | * @param mixed $default Default value if name is unknown |
329 | - * @return mixed Configuration value |
|
329 | + * @return string Configuration value |
|
330 | 330 | */ |
331 | 331 | protected function getConfig( $name, $default = null ) |
332 | 332 | { |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function getName() |
30 | 30 | { |
31 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Product export' ); |
|
31 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Product export'); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function getDescription() |
41 | 41 | { |
42 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Exports all available products' ); |
|
42 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Exports all available products'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | public function run() |
52 | 52 | { |
53 | 53 | $container = $this->createContainer(); |
54 | - $this->export( $container, false ); |
|
54 | + $this->export($container, false); |
|
55 | 55 | $container->close(); |
56 | 56 | } |
57 | 57 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @param \Aimeos\MW\Container\Content\Iface $content File content object |
63 | 63 | * @param \Aimeos\MShop\Product\Item\Iface[] $items List of product items |
64 | 64 | */ |
65 | - protected function addItems( \Aimeos\MW\Container\Content\Iface $content, array $items ) |
|
65 | + protected function addItems(\Aimeos\MW\Container\Content\Iface $content, array $items) |
|
66 | 66 | { |
67 | 67 | /** controller/jobs/product/export/standard/template-items |
68 | 68 | * Relative path to the XML items template of the product site map job controller. |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | $view->exportItems = $items; |
96 | 96 | |
97 | - $content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) ); |
|
97 | + $content->add($view->render($context->getConfig()->get($tplconf, $default))); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @see controller/jobs/product/export/max-items |
124 | 124 | * @see controller/jobs/product/export/max-query |
125 | 125 | */ |
126 | - $location = $config->get( 'controller/jobs/product/export/location' ); |
|
126 | + $location = $config->get('controller/jobs/product/export/location'); |
|
127 | 127 | |
128 | 128 | /** controller/jobs/product/export/standard/container/type |
129 | 129 | * List of file container options for the export files |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @see controller/jobs/product/export/max-items |
141 | 141 | * @see controller/jobs/product/export/max-query |
142 | 142 | */ |
143 | - $container = $config->get( 'controller/jobs/product/export/standard/container/type', 'Directory' ); |
|
143 | + $container = $config->get('controller/jobs/product/export/standard/container/type', 'Directory'); |
|
144 | 144 | |
145 | 145 | /** controller/jobs/product/export/standard/container/content |
146 | 146 | * List of file container options for the export files |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @see controller/jobs/product/export/max-items |
158 | 158 | * @see controller/jobs/product/export/max-query |
159 | 159 | */ |
160 | - $content = $config->get( 'controller/jobs/product/export/standard/container/content', 'Binary' ); |
|
160 | + $content = $config->get('controller/jobs/product/export/standard/container/content', 'Binary'); |
|
161 | 161 | |
162 | 162 | /** controller/jobs/product/export/standard/container/options |
163 | 163 | * List of file container options for the export files |
@@ -174,15 +174,15 @@ discard block |
||
174 | 174 | * @see controller/jobs/product/export/max-items |
175 | 175 | * @see controller/jobs/product/export/max-query |
176 | 176 | */ |
177 | - $options = $config->get( 'controller/jobs/product/export/standard/container/options', [] ); |
|
177 | + $options = $config->get('controller/jobs/product/export/standard/container/options', []); |
|
178 | 178 | |
179 | - if( $location === null ) |
|
179 | + if ($location === null) |
|
180 | 180 | { |
181 | - $msg = sprintf( 'Required configuration for "%1$s" is missing', 'controller/jobs/product/export/location' ); |
|
182 | - throw new \Aimeos\Controller\Jobs\Exception( $msg ); |
|
181 | + $msg = sprintf('Required configuration for "%1$s" is missing', 'controller/jobs/product/export/location'); |
|
182 | + throw new \Aimeos\Controller\Jobs\Exception($msg); |
|
183 | 183 | } |
184 | 184 | |
185 | - return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options ); |
|
185 | + return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * @param integer $filenum New file number |
194 | 194 | * @return \Aimeos\MW\Container\Content\Iface New content object |
195 | 195 | */ |
196 | - protected function createContent( \Aimeos\MW\Container\Iface $container, $filenum ) |
|
196 | + protected function createContent(\Aimeos\MW\Container\Iface $container, $filenum) |
|
197 | 197 | { |
198 | 198 | /** controller/jobs/product/export/standard/template-header |
199 | 199 | * Relative path to the XML site map header template of the product site map job controller. |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | $context = $this->getContext(); |
224 | 224 | $view = $context->getView(); |
225 | 225 | |
226 | - $content = $container->create( $this->getFilename( $filenum ) ); |
|
227 | - $content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) ); |
|
228 | - $container->add( $content ); |
|
226 | + $content = $container->create($this->getFilename($filenum)); |
|
227 | + $content->add($view->render($context->getConfig()->get($tplconf, $default))); |
|
228 | + $container->add($content); |
|
229 | 229 | |
230 | 230 | return $content; |
231 | 231 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @param \Aimeos\MW\Container\Content\Iface $content |
238 | 238 | */ |
239 | - protected function closeContent( \Aimeos\MW\Container\Content\Iface $content ) |
|
239 | + protected function closeContent(\Aimeos\MW\Container\Content\Iface $content) |
|
240 | 240 | { |
241 | 241 | /** controller/jobs/product/export/standard/template-footer |
242 | 242 | * Relative path to the XML site map footer template of the product site map job controller. |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | $context = $this->getContext(); |
267 | 267 | $view = $context->getView(); |
268 | 268 | |
269 | - $content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) ); |
|
269 | + $content->add($view->render($context->getConfig()->get($tplconf, $default))); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -277,45 +277,45 @@ discard block |
||
277 | 277 | * @param boolean $default True to filter exported products by default criteria |
278 | 278 | * @return array List of content (file) names |
279 | 279 | */ |
280 | - protected function export( \Aimeos\MW\Container\Iface $container, $default = true ) |
|
280 | + protected function export(\Aimeos\MW\Container\Iface $container, $default = true) |
|
281 | 281 | { |
282 | - $domains = array( 'attribute', 'media', 'price', 'product', 'text' ); |
|
282 | + $domains = array('attribute', 'media', 'price', 'product', 'text'); |
|
283 | 283 | |
284 | - $domains = $this->getConfig( 'domains', $domains ); |
|
285 | - $maxItems = $this->getConfig( 'max-items', 10000 ); |
|
286 | - $maxQuery = $this->getConfig( 'max-query', 1000 ); |
|
284 | + $domains = $this->getConfig('domains', $domains); |
|
285 | + $maxItems = $this->getConfig('max-items', 10000); |
|
286 | + $maxQuery = $this->getConfig('max-query', 1000); |
|
287 | 287 | |
288 | 288 | $start = 0; $filenum = 1; |
289 | 289 | $names = []; |
290 | 290 | |
291 | - $productManager = \Aimeos\MShop::create( $this->getContext(), 'product' ); |
|
291 | + $productManager = \Aimeos\MShop::create($this->getContext(), 'product'); |
|
292 | 292 | |
293 | - $search = $productManager->createSearch( $default ); |
|
294 | - $search->setSortations( array( $search->sort( '+', 'product.id' ) ) ); |
|
295 | - $search->setSlice( 0, $maxQuery ); |
|
293 | + $search = $productManager->createSearch($default); |
|
294 | + $search->setSortations(array($search->sort('+', 'product.id'))); |
|
295 | + $search->setSlice(0, $maxQuery); |
|
296 | 296 | |
297 | - $content = $this->createContent( $container, $filenum ); |
|
297 | + $content = $this->createContent($container, $filenum); |
|
298 | 298 | $names[] = $content->getResource(); |
299 | 299 | |
300 | 300 | do |
301 | 301 | { |
302 | - $items = $productManager->searchItems( $search, $domains ); |
|
303 | - $this->addItems( $content, $items ); |
|
302 | + $items = $productManager->searchItems($search, $domains); |
|
303 | + $this->addItems($content, $items); |
|
304 | 304 | |
305 | - $count = count( $items ); |
|
305 | + $count = count($items); |
|
306 | 306 | $start += $count; |
307 | - $search->setSlice( $start, $maxQuery ); |
|
307 | + $search->setSlice($start, $maxQuery); |
|
308 | 308 | |
309 | - if( $start + $maxQuery > $maxItems * $filenum ) |
|
309 | + if ($start + $maxQuery > $maxItems * $filenum) |
|
310 | 310 | { |
311 | - $this->closeContent( $content ); |
|
312 | - $content = $this->createContent( $container, ++$filenum ); |
|
311 | + $this->closeContent($content); |
|
312 | + $content = $this->createContent($container, ++$filenum); |
|
313 | 313 | $names[] = $content->getResource(); |
314 | 314 | } |
315 | 315 | } |
316 | - while( $count >= $search->getSliceSize() ); |
|
316 | + while ($count >= $search->getSliceSize()); |
|
317 | 317 | |
318 | - $this->closeContent( $content ); |
|
318 | + $this->closeContent($content); |
|
319 | 319 | |
320 | 320 | return $names; |
321 | 321 | } |
@@ -328,11 +328,11 @@ discard block |
||
328 | 328 | * @param mixed $default Default value if name is unknown |
329 | 329 | * @return mixed Configuration value |
330 | 330 | */ |
331 | - protected function getConfig( $name, $default = null ) |
|
331 | + protected function getConfig($name, $default = null) |
|
332 | 332 | { |
333 | 333 | $config = $this->getContext()->getConfig(); |
334 | 334 | |
335 | - switch( $name ) |
|
335 | + switch ($name) |
|
336 | 336 | { |
337 | 337 | case 'domain': |
338 | 338 | /** controller/jobs/product/export/domains |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * @see controller/jobs/product/export/max-items |
356 | 356 | * @see controller/jobs/product/export/max-query |
357 | 357 | */ |
358 | - return $config->get( 'controller/jobs/product/export/domains', $default ); |
|
358 | + return $config->get('controller/jobs/product/export/domains', $default); |
|
359 | 359 | |
360 | 360 | case 'max-items': |
361 | 361 | /** controller/jobs/product/export/max-items |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * @see controller/jobs/product/export/max-query |
379 | 379 | * @see controller/jobs/product/export/domains |
380 | 380 | */ |
381 | - return $config->get( 'controller/jobs/product/export/max-items', $default ); |
|
381 | + return $config->get('controller/jobs/product/export/max-items', $default); |
|
382 | 382 | |
383 | 383 | case 'max-query': |
384 | 384 | /** controller/jobs/product/export/max-query |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | * @see controller/jobs/product/export/max-items |
402 | 402 | * @see controller/jobs/product/export/domains |
403 | 403 | */ |
404 | - return $config->get( 'controller/jobs/product/export/max-query', $default ); |
|
404 | + return $config->get('controller/jobs/product/export/max-query', $default); |
|
405 | 405 | |
406 | 406 | case 'filename': |
407 | 407 | /** controller/jobs/product/export/filename |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * @see controller/jobs/product/export/max-query |
423 | 423 | * @see controller/jobs/product/export/domains |
424 | 424 | */ |
425 | - return $config->get( 'controller/jobs/product/export/filename', $default ); |
|
425 | + return $config->get('controller/jobs/product/export/filename', $default); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | return $default; |
@@ -435,8 +435,8 @@ discard block |
||
435 | 435 | * @param integer $number Current file number |
436 | 436 | * @return string New file name |
437 | 437 | */ |
438 | - protected function getFilename( $number ) |
|
438 | + protected function getFilename($number) |
|
439 | 439 | { |
440 | - return sprintf( $this->getConfig( 'filename', 'aimeos-products-%1$d_%2$s.xml' ), $number, date( 'Y-m-d_H:i:s' ) ); |
|
440 | + return sprintf($this->getConfig('filename', 'aimeos-products-%1$d_%2$s.xml'), $number, date('Y-m-d_H:i:s')); |
|
441 | 441 | } |
442 | 442 | } |
@@ -248,6 +248,9 @@ |
||
248 | 248 | } |
249 | 249 | |
250 | 250 | |
251 | + /** |
|
252 | + * @param string $catcode |
|
253 | + */ |
|
251 | 254 | protected function get( $catcode, array $domains = [] ) |
252 | 255 | { |
253 | 256 | $manager = \Aimeos\MShop\Catalog\Manager\Factory::create( $this->context ); |
@@ -18,65 +18,65 @@ discard block |
||
18 | 18 | |
19 | 19 | protected function setUp() |
20 | 20 | { |
21 | - \Aimeos\MShop::cache( true ); |
|
21 | + \Aimeos\MShop::cache(true); |
|
22 | 22 | |
23 | 23 | $this->context = \TestHelperJobs::getContext(); |
24 | 24 | $this->aimeos = \TestHelperJobs::getAimeos(); |
25 | 25 | $config = $this->context->getConfig(); |
26 | 26 | |
27 | - $config->set( 'controller/jobs/catalog/import/csv/skip-lines', 1 ); |
|
28 | - $config->set( 'controller/jobs/catalog/import/csv/location', __DIR__ . '/_testfiles/valid' ); |
|
27 | + $config->set('controller/jobs/catalog/import/csv/skip-lines', 1); |
|
28 | + $config->set('controller/jobs/catalog/import/csv/location', __DIR__ . '/_testfiles/valid'); |
|
29 | 29 | |
30 | - $this->object = new \Aimeos\Controller\Jobs\Catalog\Import\Csv\Standard( $this->context, $this->aimeos ); |
|
30 | + $this->object = new \Aimeos\Controller\Jobs\Catalog\Import\Csv\Standard($this->context, $this->aimeos); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
34 | 34 | protected function tearDown() |
35 | 35 | { |
36 | - \Aimeos\MShop::cache( false ); |
|
36 | + \Aimeos\MShop::cache(false); |
|
37 | 37 | \Aimeos\MShop::clear(); |
38 | 38 | |
39 | 39 | $this->object = null; |
40 | 40 | |
41 | - if( file_exists( 'tmp/import.zip' ) ) { |
|
42 | - unlink( 'tmp/import.zip' ); |
|
41 | + if (file_exists('tmp/import.zip')) { |
|
42 | + unlink('tmp/import.zip'); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | 46 | |
47 | 47 | public function testGetName() |
48 | 48 | { |
49 | - $this->assertEquals( 'Catalog import CSV', $this->object->getName() ); |
|
49 | + $this->assertEquals('Catalog import CSV', $this->object->getName()); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | |
53 | 53 | public function testGetDescription() |
54 | 54 | { |
55 | 55 | $text = 'Imports new and updates existing categories from CSV files'; |
56 | - $this->assertEquals( $text, $this->object->getDescription() ); |
|
56 | + $this->assertEquals($text, $this->object->getDescription()); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
60 | 60 | public function testRun() |
61 | 61 | { |
62 | - $catcodes = array( 'job_csv_test', 'job_csv_test2', 'job_csv_test3', 'job_csv_test4' ); |
|
63 | - $domains = array( 'media', 'text' ); |
|
62 | + $catcodes = array('job_csv_test', 'job_csv_test2', 'job_csv_test3', 'job_csv_test4'); |
|
63 | + $domains = array('media', 'text'); |
|
64 | 64 | |
65 | 65 | $convert = array( |
66 | 66 | 1 => 'Text/LatinUTF8', |
67 | 67 | ); |
68 | 68 | |
69 | - $this->context->getConfig()->set( 'controller/jobs/catalog/import/csv/converter', $convert ); |
|
69 | + $this->context->getConfig()->set('controller/jobs/catalog/import/csv/converter', $convert); |
|
70 | 70 | |
71 | 71 | $this->object->run(); |
72 | 72 | |
73 | - $tree = $this->get( 'job_csv_test', $domains ); |
|
74 | - $this->delete( $tree, $domains ); |
|
73 | + $tree = $this->get('job_csv_test', $domains); |
|
74 | + $this->delete($tree, $domains); |
|
75 | 75 | |
76 | - $this->assertEquals( 2, count( $tree->getListItems() ) ); |
|
76 | + $this->assertEquals(2, count($tree->getListItems())); |
|
77 | 77 | |
78 | - foreach( $tree->getChildren() as $node ) { |
|
79 | - $this->assertEquals( 2, count( $node->getListItems() ) ); |
|
78 | + foreach ($tree->getChildren() as $node) { |
|
79 | + $this->assertEquals(2, count($node->getListItems())); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | $this->object->run(); |
87 | 87 | $this->object->run(); |
88 | 88 | |
89 | - $tree = $this->get( 'job_csv_test', ['media', 'text'] ); |
|
90 | - $this->delete( $tree, ['media', 'text'] ); |
|
89 | + $tree = $this->get('job_csv_test', ['media', 'text']); |
|
90 | + $this->delete($tree, ['media', 'text']); |
|
91 | 91 | |
92 | - $this->assertEquals( 2, count( $tree->getListItems() ) ); |
|
92 | + $this->assertEquals(2, count($tree->getListItems())); |
|
93 | 93 | |
94 | - foreach( $tree->getChildren() as $node ) { |
|
95 | - $this->assertEquals( 2, count( $node->getListItems() ) ); |
|
94 | + foreach ($tree->getChildren() as $node) { |
|
95 | + $this->assertEquals(2, count($node->getListItems())); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
@@ -100,18 +100,18 @@ discard block |
||
100 | 100 | public function testRunPosition() |
101 | 101 | { |
102 | 102 | $config = $this->context->getConfig(); |
103 | - $mapping = $config->set( 'controller/jobs/catalog/import/csv/mapping', [] ); |
|
104 | - $mapping['item'] = array( 0 => 'catalog.label', 1 => 'catalog.code', 2 => 'catalog.parent' ); |
|
103 | + $mapping = $config->set('controller/jobs/catalog/import/csv/mapping', []); |
|
104 | + $mapping['item'] = array(0 => 'catalog.label', 1 => 'catalog.code', 2 => 'catalog.parent'); |
|
105 | 105 | |
106 | - $config->set( 'controller/jobs/catalog/import/csv/mapping', $mapping ); |
|
107 | - $config->set( 'controller/jobs/catalog/import/csv/location', __DIR__ . '/_testfiles/position' ); |
|
106 | + $config->set('controller/jobs/catalog/import/csv/mapping', $mapping); |
|
107 | + $config->set('controller/jobs/catalog/import/csv/location', __DIR__ . '/_testfiles/position'); |
|
108 | 108 | |
109 | 109 | $this->object->run(); |
110 | 110 | |
111 | - $tree = $this->get( 'job_csv_test' ); |
|
112 | - $this->delete( $tree ); |
|
111 | + $tree = $this->get('job_csv_test'); |
|
112 | + $this->delete($tree); |
|
113 | 113 | |
114 | - $this->assertEquals( 1, count( $tree->getChildren() ) ); |
|
114 | + $this->assertEquals(1, count($tree->getChildren())); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | ), |
136 | 136 | ); |
137 | 137 | |
138 | - $this->context->getConfig()->set( 'controller/jobs/catalog/import/csv/mapping', $mapping ); |
|
138 | + $this->context->getConfig()->set('controller/jobs/catalog/import/csv/mapping', $mapping); |
|
139 | 139 | |
140 | 140 | $this->object->run(); |
141 | 141 | |
142 | - $tree = $this->get( 'job_csv_test' ); |
|
143 | - $this->delete( $tree ); |
|
142 | + $tree = $this->get('job_csv_test'); |
|
143 | + $this->delete($tree); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | ), |
153 | 153 | ); |
154 | 154 | |
155 | - $this->context->getConfig()->set( 'controller/jobs/catalog/import/csv/mapping', $mapping ); |
|
155 | + $this->context->getConfig()->set('controller/jobs/catalog/import/csv/mapping', $mapping); |
|
156 | 156 | |
157 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
157 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
158 | 158 | $this->object->run(); |
159 | 159 | } |
160 | 160 | |
@@ -178,15 +178,15 @@ discard block |
||
178 | 178 | ), |
179 | 179 | ); |
180 | 180 | |
181 | - $this->context->getConfig()->set( 'controller/jobs/catalog/import/csv/mapping', $mapping ); |
|
181 | + $this->context->getConfig()->set('controller/jobs/catalog/import/csv/mapping', $mapping); |
|
182 | 182 | |
183 | 183 | $config = $this->context->getConfig(); |
184 | - $config->set( 'controller/jobs/catalog/import/csv/skip-lines', 0 ); |
|
185 | - $config->set( 'controller/jobs/catalog/import/csv/location', __DIR__ . '/_testfiles/invalid' ); |
|
184 | + $config->set('controller/jobs/catalog/import/csv/skip-lines', 0); |
|
185 | + $config->set('controller/jobs/catalog/import/csv/location', __DIR__ . '/_testfiles/invalid'); |
|
186 | 186 | |
187 | - $this->object = new \Aimeos\Controller\Jobs\Catalog\Import\Csv\Standard( $this->context, $this->aimeos ); |
|
187 | + $this->object = new \Aimeos\Controller\Jobs\Catalog\Import\Csv\Standard($this->context, $this->aimeos); |
|
188 | 188 | |
189 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
189 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
190 | 190 | $this->object->run(); |
191 | 191 | } |
192 | 192 | |
@@ -194,65 +194,65 @@ discard block |
||
194 | 194 | public function testRunBackup() |
195 | 195 | { |
196 | 196 | $config = $this->context->getConfig(); |
197 | - $config->set( 'controller/jobs/catalog/import/csv/container/type', 'Zip' ); |
|
198 | - $config->set( 'controller/jobs/catalog/import/csv/location', 'tmp/import.zip' ); |
|
199 | - $config->set( 'controller/jobs/catalog/import/csv/backup', 'tmp/test-%Y-%m-%d.zip' ); |
|
197 | + $config->set('controller/jobs/catalog/import/csv/container/type', 'Zip'); |
|
198 | + $config->set('controller/jobs/catalog/import/csv/location', 'tmp/import.zip'); |
|
199 | + $config->set('controller/jobs/catalog/import/csv/backup', 'tmp/test-%Y-%m-%d.zip'); |
|
200 | 200 | |
201 | - if( copy( __DIR__ . '/_testfiles/import.zip', 'tmp/import.zip' ) === false ) { |
|
202 | - throw new \RuntimeException( 'Unable to copy test file' ); |
|
201 | + if (copy(__DIR__ . '/_testfiles/import.zip', 'tmp/import.zip') === false) { |
|
202 | + throw new \RuntimeException('Unable to copy test file'); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | $this->object->run(); |
206 | 206 | |
207 | - $filename = strftime( 'tmp/test-%Y-%m-%d.zip' ); |
|
208 | - $this->assertTrue( file_exists( $filename ) ); |
|
207 | + $filename = strftime('tmp/test-%Y-%m-%d.zip'); |
|
208 | + $this->assertTrue(file_exists($filename)); |
|
209 | 209 | |
210 | - unlink( $filename ); |
|
210 | + unlink($filename); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
214 | 214 | public function testRunBackupInvalid() |
215 | 215 | { |
216 | 216 | $config = $this->context->getConfig(); |
217 | - $config->set( 'controller/jobs/catalog/import/csv/container/type', 'Zip' ); |
|
218 | - $config->set( 'controller/jobs/catalog/import/csv/location', 'tmp/import.zip' ); |
|
219 | - $config->set( 'controller/jobs/catalog/import/csv/backup', 'tmp/notexist/import.zip' ); |
|
217 | + $config->set('controller/jobs/catalog/import/csv/container/type', 'Zip'); |
|
218 | + $config->set('controller/jobs/catalog/import/csv/location', 'tmp/import.zip'); |
|
219 | + $config->set('controller/jobs/catalog/import/csv/backup', 'tmp/notexist/import.zip'); |
|
220 | 220 | |
221 | - if( copy( __DIR__ . '/_testfiles/import.zip', 'tmp/import.zip' ) === false ) { |
|
222 | - throw new \RuntimeException( 'Unable to copy test file' ); |
|
221 | + if (copy(__DIR__ . '/_testfiles/import.zip', 'tmp/import.zip') === false) { |
|
222 | + throw new \RuntimeException('Unable to copy test file'); |
|
223 | 223 | } |
224 | 224 | |
225 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
225 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
226 | 226 | $this->object->run(); |
227 | 227 | } |
228 | 228 | |
229 | 229 | |
230 | - protected function delete( \Aimeos\MShop\Catalog\Item\Iface $tree, array $domains = [] ) |
|
230 | + protected function delete(\Aimeos\MShop\Catalog\Item\Iface $tree, array $domains = []) |
|
231 | 231 | { |
232 | - $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::create( $this->context ); |
|
232 | + $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::create($this->context); |
|
233 | 233 | |
234 | - foreach( $domains as $domain ) |
|
234 | + foreach ($domains as $domain) |
|
235 | 235 | { |
236 | - $manager = \Aimeos\MShop::create( $this->context, $domain ); |
|
236 | + $manager = \Aimeos\MShop::create($this->context, $domain); |
|
237 | 237 | |
238 | - foreach( $tree->getListItems( $domain ) as $listItem ) { |
|
239 | - $manager->deleteItem( $listItem->getRefItem()->getId() ); |
|
238 | + foreach ($tree->getListItems($domain) as $listItem) { |
|
239 | + $manager->deleteItem($listItem->getRefItem()->getId()); |
|
240 | 240 | } |
241 | 241 | } |
242 | 242 | |
243 | - foreach( $tree->getChildren() as $node ) { |
|
244 | - $this->delete( $node, $domains ); |
|
243 | + foreach ($tree->getChildren() as $node) { |
|
244 | + $this->delete($node, $domains); |
|
245 | 245 | } |
246 | 246 | |
247 | - $catalogManager->deleteItem( $tree->getId() ); |
|
247 | + $catalogManager->deleteItem($tree->getId()); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
251 | - protected function get( $catcode, array $domains = [] ) |
|
251 | + protected function get($catcode, array $domains = []) |
|
252 | 252 | { |
253 | - $manager = \Aimeos\MShop\Catalog\Manager\Factory::create( $this->context ); |
|
254 | - $root = $manager->findItem( $catcode ); |
|
253 | + $manager = \Aimeos\MShop\Catalog\Manager\Factory::create($this->context); |
|
254 | + $root = $manager->findItem($catcode); |
|
255 | 255 | |
256 | - return $manager->getTree( $root->getId(), $domains, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ); |
|
256 | + return $manager->getTree($root->getId(), $domains, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | \ No newline at end of file |
@@ -73,6 +73,9 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | |
76 | + /** |
|
77 | + * @param integer $cnt |
|
78 | + */ |
|
76 | 79 | protected function addAttribute( array $data, $cnt ) |
77 | 80 | { |
78 | 81 | $data[] = 'length'; // type |
@@ -86,6 +89,9 @@ discard block |
||
86 | 89 | } |
87 | 90 | |
88 | 91 | |
92 | + /** |
|
93 | + * @param integer $cnt |
|
94 | + */ |
|
89 | 95 | protected function addMedia( array $data, $cnt ) |
90 | 96 | { |
91 | 97 | $data[] = "/path/to/image-$cnt.jpg"; // url |
@@ -94,6 +100,9 @@ discard block |
||
94 | 100 | } |
95 | 101 | |
96 | 102 | |
103 | + /** |
|
104 | + * @param integer $cnt |
|
105 | + */ |
|
97 | 106 | protected function addPrice( array $data, $cnt ) |
98 | 107 | { |
99 | 108 | $data[] = 1; // quantity |
@@ -105,6 +114,9 @@ discard block |
||
105 | 114 | } |
106 | 115 | |
107 | 116 | |
117 | + /** |
|
118 | + * @param integer $cnt |
|
119 | + */ |
|
108 | 120 | protected function addProduct( array $data, $cnt ) |
109 | 121 | { |
110 | 122 | $data[] = 'import-' . $cnt; // code |
@@ -116,6 +128,9 @@ discard block |
||
116 | 128 | } |
117 | 129 | |
118 | 130 | |
131 | + /** |
|
132 | + * @param integer $cnt |
|
133 | + */ |
|
119 | 134 | protected function addProductRef( array $data, $cnt ) |
120 | 135 | { |
121 | 136 | $data[] = 'import-' . ($cnt % 100); // code |
@@ -125,6 +140,9 @@ discard block |
||
125 | 140 | } |
126 | 141 | |
127 | 142 | |
143 | + /** |
|
144 | + * @param integer $cnt |
|
145 | + */ |
|
128 | 146 | protected function addProperty( array $data, $cnt ) |
129 | 147 | { |
130 | 148 | $data[] = 'package-weight'; // type |
@@ -134,6 +152,9 @@ discard block |
||
134 | 152 | } |
135 | 153 | |
136 | 154 | |
155 | + /** |
|
156 | + * @param integer $cnt |
|
157 | + */ |
|
137 | 158 | protected function addText( array $data, $cnt ) |
138 | 159 | { |
139 | 160 | $data[] = 'name'; // type |
@@ -17,31 +17,31 @@ discard block |
||
17 | 17 | $this->context = \TestHelperJobs::getContext('unitperf'); |
18 | 18 | |
19 | 19 | $config = $this->context->getConfig(); |
20 | - $config->set( 'controller/jobs/product/import/csv/location', 'tmp/product-import.zip' ); |
|
21 | - $config->set( 'controller/jobs/product/import/csv/container/type', 'Zip' ); |
|
22 | - $config->set( 'controller/jobs/product/import/csv/container/content', 'CSV' ); |
|
23 | - $config->set( 'controller/jobs/product/import/csv/mapping', $this->getMapping() ); |
|
20 | + $config->set('controller/jobs/product/import/csv/location', 'tmp/product-import.zip'); |
|
21 | + $config->set('controller/jobs/product/import/csv/container/type', 'Zip'); |
|
22 | + $config->set('controller/jobs/product/import/csv/container/content', 'CSV'); |
|
23 | + $config->set('controller/jobs/product/import/csv/mapping', $this->getMapping()); |
|
24 | 24 | |
25 | - $container = \Aimeos\MW\Container\Factory::getContainer( 'tmp/product-import.zip', 'Zip', 'CSV', [] ); |
|
25 | + $container = \Aimeos\MW\Container\Factory::getContainer('tmp/product-import.zip', 'Zip', 'CSV', []); |
|
26 | 26 | |
27 | - $content = $container->create( 'product.csv' ); |
|
27 | + $content = $container->create('product.csv'); |
|
28 | 28 | |
29 | - for( $i = 0; $i < 1000; $i++ ) |
|
29 | + for ($i = 0; $i < 1000; $i++) |
|
30 | 30 | { |
31 | 31 | $data = []; |
32 | 32 | |
33 | - $data = $this->addProduct( $data, $i ); |
|
34 | - $data = $this->addText( $data, $i ); |
|
35 | - $data = $this->addMedia( $data, $i ); |
|
36 | - $data = $this->addPrice( $data, $i ); |
|
37 | - $data = $this->addAttribute( $data, $i ); |
|
38 | - $data = $this->addProductRef( $data, $i ); |
|
39 | - $data = $this->addProperty( $data, $i ); |
|
33 | + $data = $this->addProduct($data, $i); |
|
34 | + $data = $this->addText($data, $i); |
|
35 | + $data = $this->addMedia($data, $i); |
|
36 | + $data = $this->addPrice($data, $i); |
|
37 | + $data = $this->addAttribute($data, $i); |
|
38 | + $data = $this->addProductRef($data, $i); |
|
39 | + $data = $this->addProperty($data, $i); |
|
40 | 40 | |
41 | - $content->add( $data ); |
|
41 | + $content->add($data); |
|
42 | 42 | } |
43 | 43 | |
44 | - $container->add( $content ); |
|
44 | + $container->add($content); |
|
45 | 45 | |
46 | 46 | $container->close(); |
47 | 47 | } |
@@ -55,25 +55,25 @@ discard block |
||
55 | 55 | $this->cleanupPrice(); |
56 | 56 | $this->cleanupProduct(); |
57 | 57 | |
58 | - unlink( 'tmp/product-import.zip' ); |
|
58 | + unlink('tmp/product-import.zip'); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
62 | 62 | public function testImport() |
63 | 63 | { |
64 | 64 | $aimeos = \TestHelperJobs::getAimeos(); |
65 | - $cntl = \Aimeos\Controller\Jobs\Product\Import\Csv\Factory::createController( $this->context, $aimeos, 'Standard' ); |
|
65 | + $cntl = \Aimeos\Controller\Jobs\Product\Import\Csv\Factory::createController($this->context, $aimeos, 'Standard'); |
|
66 | 66 | |
67 | - $start = microtime( true ); |
|
67 | + $start = microtime(true); |
|
68 | 68 | |
69 | 69 | $cntl->run(); |
70 | 70 | |
71 | - $stop = microtime( true ); |
|
72 | - echo "\n product import CSV: " . ( ( $stop - $start ) ) . " sec\n"; |
|
71 | + $stop = microtime(true); |
|
72 | + echo "\n product import CSV: " . (($stop - $start)) . " sec\n"; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
76 | - protected function addAttribute( array $data, $cnt ) |
|
76 | + protected function addAttribute(array $data, $cnt) |
|
77 | 77 | { |
78 | 78 | $data[] = 'length'; // type |
79 | 79 | $data[] = 'import-' . ($cnt % 30); // code |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | |
89 | - protected function addMedia( array $data, $cnt ) |
|
89 | + protected function addMedia(array $data, $cnt) |
|
90 | 90 | { |
91 | 91 | $data[] = "/path/to/image-$cnt.jpg"; // url |
92 | 92 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | } |
95 | 95 | |
96 | 96 | |
97 | - protected function addPrice( array $data, $cnt ) |
|
97 | + protected function addPrice(array $data, $cnt) |
|
98 | 98 | { |
99 | 99 | $data[] = 1; // quantity |
100 | 100 | $data[] = 'import-' . $cnt; // label |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | |
108 | - protected function addProduct( array $data, $cnt ) |
|
108 | + protected function addProduct(array $data, $cnt) |
|
109 | 109 | { |
110 | 110 | $data[] = 'import-' . $cnt; // code |
111 | 111 | $data[] = 'import-' . $cnt; // label |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | } |
117 | 117 | |
118 | 118 | |
119 | - protected function addProductRef( array $data, $cnt ) |
|
119 | + protected function addProductRef(array $data, $cnt) |
|
120 | 120 | { |
121 | 121 | $data[] = 'import-' . ($cnt % 100); // code |
122 | 122 | $data[] = 'suggestion'; // type |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | |
128 | - protected function addProperty( array $data, $cnt ) |
|
128 | + protected function addProperty(array $data, $cnt) |
|
129 | 129 | { |
130 | 130 | $data[] = 'package-weight'; // type |
131 | 131 | $data[] = '0.5'; // value |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | } |
135 | 135 | |
136 | 136 | |
137 | - protected function addText( array $data, $cnt ) |
|
137 | + protected function addText(array $data, $cnt) |
|
138 | 138 | { |
139 | 139 | $data[] = 'name'; // type |
140 | 140 | $data[] = 'import-name-' . $cnt; //content |
@@ -149,132 +149,132 @@ discard block |
||
149 | 149 | |
150 | 150 | protected function cleanupAttribute() |
151 | 151 | { |
152 | - $manager = \Aimeos\MShop\Attribute\Manager\Factory::create( $this->context ); |
|
152 | + $manager = \Aimeos\MShop\Attribute\Manager\Factory::create($this->context); |
|
153 | 153 | |
154 | 154 | $search = $manager->createSearch(); |
155 | 155 | $expr = array( |
156 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
157 | - $search->compare( '==', 'attribute.label', 'import-%' ), |
|
156 | + $search->compare('==', 'attribute.domain', 'product'), |
|
157 | + $search->compare('==', 'attribute.label', 'import-%'), |
|
158 | 158 | ); |
159 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
160 | - $search->setSortations( array( $search->sort( '+', 'attribute.id' ) ) ); |
|
159 | + $search->setConditions($search->combine('&&', $expr)); |
|
160 | + $search->setSortations(array($search->sort('+', 'attribute.id'))); |
|
161 | 161 | |
162 | 162 | $start = 0; |
163 | 163 | |
164 | 164 | do |
165 | 165 | { |
166 | - $result = $manager->searchItems( $search ); |
|
167 | - $manager->deleteItems( array_keys( $result ) ); |
|
166 | + $result = $manager->searchItems($search); |
|
167 | + $manager->deleteItems(array_keys($result)); |
|
168 | 168 | |
169 | - $count = count( $result ); |
|
169 | + $count = count($result); |
|
170 | 170 | $start += $count; |
171 | - $search->setSlice( $start ); |
|
171 | + $search->setSlice($start); |
|
172 | 172 | } |
173 | - while( $count == $search->getSliceSize() ); |
|
173 | + while ($count == $search->getSliceSize()); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | |
177 | 177 | protected function cleanupMedia() |
178 | 178 | { |
179 | - $manager = \Aimeos\MShop\Media\Manager\Factory::create( $this->context ); |
|
179 | + $manager = \Aimeos\MShop\Media\Manager\Factory::create($this->context); |
|
180 | 180 | |
181 | 181 | $search = $manager->createSearch(); |
182 | 182 | $expr = array( |
183 | - $search->compare( '==', 'media.domain', 'product' ), |
|
184 | - $search->compare( '==', 'media.label', 'import-%' ), |
|
183 | + $search->compare('==', 'media.domain', 'product'), |
|
184 | + $search->compare('==', 'media.label', 'import-%'), |
|
185 | 185 | ); |
186 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
187 | - $search->setSortations( array( $search->sort( '+', 'media.id' ) ) ); |
|
186 | + $search->setConditions($search->combine('&&', $expr)); |
|
187 | + $search->setSortations(array($search->sort('+', 'media.id'))); |
|
188 | 188 | |
189 | 189 | $start = 0; |
190 | 190 | |
191 | 191 | do |
192 | 192 | { |
193 | - $result = $manager->searchItems( $search ); |
|
194 | - $manager->deleteItems( array_keys( $result ) ); |
|
193 | + $result = $manager->searchItems($search); |
|
194 | + $manager->deleteItems(array_keys($result)); |
|
195 | 195 | |
196 | - $count = count( $result ); |
|
196 | + $count = count($result); |
|
197 | 197 | $start += $count; |
198 | - $search->setSlice( $start ); |
|
198 | + $search->setSlice($start); |
|
199 | 199 | } |
200 | - while( $count == $search->getSliceSize() ); |
|
200 | + while ($count == $search->getSliceSize()); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | |
204 | 204 | protected function cleanupPrice() |
205 | 205 | { |
206 | - $manager = \Aimeos\MShop\Price\Manager\Factory::create( $this->context ); |
|
206 | + $manager = \Aimeos\MShop\Price\Manager\Factory::create($this->context); |
|
207 | 207 | |
208 | 208 | $search = $manager->createSearch(); |
209 | 209 | $expr = array( |
210 | - $search->compare( '==', 'price.domain', 'product' ), |
|
211 | - $search->compare( '==', 'price.label', 'import-%' ), |
|
210 | + $search->compare('==', 'price.domain', 'product'), |
|
211 | + $search->compare('==', 'price.label', 'import-%'), |
|
212 | 212 | ); |
213 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
214 | - $search->setSortations( array( $search->sort( '+', 'price.id' ) ) ); |
|
213 | + $search->setConditions($search->combine('&&', $expr)); |
|
214 | + $search->setSortations(array($search->sort('+', 'price.id'))); |
|
215 | 215 | |
216 | 216 | $start = 0; |
217 | 217 | |
218 | 218 | do |
219 | 219 | { |
220 | - $result = $manager->searchItems( $search ); |
|
221 | - $manager->deleteItems( array_keys( $result ) ); |
|
220 | + $result = $manager->searchItems($search); |
|
221 | + $manager->deleteItems(array_keys($result)); |
|
222 | 222 | |
223 | - $count = count( $result ); |
|
223 | + $count = count($result); |
|
224 | 224 | $start += $count; |
225 | - $search->setSlice( $start ); |
|
225 | + $search->setSlice($start); |
|
226 | 226 | } |
227 | - while( $count == $search->getSliceSize() ); |
|
227 | + while ($count == $search->getSliceSize()); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | |
231 | 231 | protected function cleanupProduct() |
232 | 232 | { |
233 | - $manager = \Aimeos\MShop\Product\Manager\Factory::create( $this->context ); |
|
233 | + $manager = \Aimeos\MShop\Product\Manager\Factory::create($this->context); |
|
234 | 234 | |
235 | 235 | $search = $manager->createSearch(); |
236 | - $search->setConditions( $search->compare( '==', 'product.code', 'import-%' ) ); |
|
237 | - $search->setSortations( array( $search->sort( '+', 'product.id' ) ) ); |
|
236 | + $search->setConditions($search->compare('==', 'product.code', 'import-%')); |
|
237 | + $search->setSortations(array($search->sort('+', 'product.id'))); |
|
238 | 238 | |
239 | 239 | $start = 0; |
240 | 240 | |
241 | 241 | do |
242 | 242 | { |
243 | - $result = $manager->searchItems( $search ); |
|
244 | - $manager->deleteItems( array_keys( $result ) ); |
|
243 | + $result = $manager->searchItems($search); |
|
244 | + $manager->deleteItems(array_keys($result)); |
|
245 | 245 | |
246 | - $count = count( $result ); |
|
246 | + $count = count($result); |
|
247 | 247 | $start += $count; |
248 | - $search->setSlice( $start ); |
|
248 | + $search->setSlice($start); |
|
249 | 249 | } |
250 | - while( $count == $search->getSliceSize() ); |
|
250 | + while ($count == $search->getSliceSize()); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | |
254 | 254 | protected function cleanupText() |
255 | 255 | { |
256 | - $manager = \Aimeos\MShop\Text\Manager\Factory::create( $this->context ); |
|
256 | + $manager = \Aimeos\MShop\Text\Manager\Factory::create($this->context); |
|
257 | 257 | |
258 | 258 | $search = $manager->createSearch(); |
259 | 259 | $expr = array( |
260 | - $search->compare( '==', 'text.domain', 'product' ), |
|
261 | - $search->compare( '==', 'text.label', 'import-%' ), |
|
260 | + $search->compare('==', 'text.domain', 'product'), |
|
261 | + $search->compare('==', 'text.label', 'import-%'), |
|
262 | 262 | ); |
263 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
264 | - $search->setSortations( array( $search->sort( '+', 'text.id' ) ) ); |
|
263 | + $search->setConditions($search->combine('&&', $expr)); |
|
264 | + $search->setSortations(array($search->sort('+', 'text.id'))); |
|
265 | 265 | |
266 | 266 | $start = 0; |
267 | 267 | |
268 | 268 | do |
269 | 269 | { |
270 | - $result = $manager->searchItems( $search ); |
|
271 | - $manager->deleteItems( array_keys( $result ) ); |
|
270 | + $result = $manager->searchItems($search); |
|
271 | + $manager->deleteItems(array_keys($result)); |
|
272 | 272 | |
273 | - $count = count( $result ); |
|
273 | + $count = count($result); |
|
274 | 274 | $start += $count; |
275 | - $search->setSlice( $start ); |
|
275 | + $search->setSlice($start); |
|
276 | 276 | } |
277 | - while( $count == $search->getSliceSize() ); |
|
277 | + while ($count == $search->getSliceSize()); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 |
@@ -42,20 +42,20 @@ discard block |
||
42 | 42 | * @param string|null $type Attribute type |
43 | 43 | * @return string|null Product ID or null if not found |
44 | 44 | */ |
45 | - public function get( $code, $type = null ) |
|
45 | + public function get($code, $type = null) |
|
46 | 46 | { |
47 | - if( isset( $this->prodmap[$code] ) ) { |
|
47 | + if (isset($this->prodmap[$code])) { |
|
48 | 48 | return $this->prodmap[$code]; |
49 | 49 | } |
50 | 50 | |
51 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'product' ); |
|
51 | + $manager = \Aimeos\MShop::create($this->getContext(), 'product'); |
|
52 | 52 | |
53 | 53 | $search = $manager->createSearch(); |
54 | - $search->setConditions( $search->compare( '==', 'product.code', $code ) ); |
|
54 | + $search->setConditions($search->compare('==', 'product.code', $code)); |
|
55 | 55 | |
56 | - $result = $manager->searchItems( $search ); |
|
56 | + $result = $manager->searchItems($search); |
|
57 | 57 | |
58 | - if( ( $item = reset( $result ) ) !== false ) |
|
58 | + if (($item = reset($result)) !== false) |
|
59 | 59 | { |
60 | 60 | $this->prodmap[$code] = $item->getId(); |
61 | 61 | return $this->prodmap[$code]; |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @param \Aimeos\MShop\Common\Item\Iface $item Product object |
70 | 70 | */ |
71 | - public function set( \Aimeos\MShop\Common\Item\Iface $item ) |
|
71 | + public function set(\Aimeos\MShop\Common\Item\Iface $item) |
|
72 | 72 | { |
73 | - $this->prodmap[ $item->getCode() ] = $item->getId(); |
|
73 | + $this->prodmap[$item->getCode()] = $item->getId(); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | \ No newline at end of file |
@@ -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::create( $context, 'catalog' ); |
|
48 | - $result = $manager->searchItems( $manager->createSearch() ); |
|
47 | + $manager = \Aimeos\MShop::create($context, 'catalog'); |
|
48 | + $result = $manager->searchItems($manager->createSearch()); |
|
49 | 49 | |
50 | - foreach( $result as $id => $item ) { |
|
51 | - $this->categories[ $item->getCode() ] = $id; |
|
50 | + foreach ($result as $id => $item) { |
|
51 | + $this->categories[$item->getCode()] = $id; |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
@@ -60,20 +60,20 @@ discard block |
||
60 | 60 | * @param string|null $type Not used |
61 | 61 | * @return string|null Catalog ID 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->categories[$code] ) ) { |
|
65 | + if (isset($this->categories[$code])) { |
|
66 | 66 | return $this->categories[$code]; |
67 | 67 | } |
68 | 68 | |
69 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'catalog' ); |
|
69 | + $manager = \Aimeos\MShop::create($this->getContext(), 'catalog'); |
|
70 | 70 | |
71 | 71 | $search = $manager->createSearch(); |
72 | - $search->setConditions( $search->compare( '==', 'catalog.code', $code ) ); |
|
72 | + $search->setConditions($search->compare('==', 'catalog.code', $code)); |
|
73 | 73 | |
74 | - $result = $manager->searchItems( $search ); |
|
74 | + $result = $manager->searchItems($search); |
|
75 | 75 | |
76 | - if( ( $item = reset( $result ) ) !== false ) |
|
76 | + if (($item = reset($result)) !== false) |
|
77 | 77 | { |
78 | 78 | $this->categories[$code] = $item->getId(); |
79 | 79 | return $item->getId(); |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @param \Aimeos\MShop\Common\Item\Iface $item Catalog object |
88 | 88 | */ |
89 | - public function set( \Aimeos\MShop\Common\Item\Iface $item ) |
|
89 | + public function set(\Aimeos\MShop\Common\Item\Iface $item) |
|
90 | 90 | { |
91 | - $this->categories[ $item->getCode() ] = $item->getId(); |
|
91 | + $this->categories[$item->getCode()] = $item->getId(); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | \ No newline at end of file |
@@ -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::create( $context, 'attribute' ); |
|
48 | - $result = $manager->searchItems( $manager->createSearch() ); |
|
47 | + $manager = \Aimeos\MShop::create($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::create( $this->getContext(), 'attribute' ); |
|
69 | + $manager = \Aimeos\MShop::create($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', $type ), |
|
73 | + $search->compare('==', 'attribute.code', $code), |
|
74 | + $search->compare('==', 'attribute.type', $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 |
@@ -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 |
@@ -74,26 +74,26 @@ discard block |
||
74 | 74 | * @see controller/common/product/import/csv/processor/text/listtypes |
75 | 75 | */ |
76 | 76 | $key = 'controller/common/product/import/csv/processor/product/listtypes'; |
77 | - $this->listTypes = $context->getConfig()->get( $key, ['default', 'suggestion'] ); |
|
77 | + $this->listTypes = $context->getConfig()->get($key, ['default', 'suggestion']); |
|
78 | 78 | |
79 | - if( $this->listTypes === null ) |
|
79 | + if ($this->listTypes === null) |
|
80 | 80 | { |
81 | 81 | $this->listTypes = []; |
82 | - $manager = \Aimeos\MShop::create( $context, 'product/lists/type' ); |
|
82 | + $manager = \Aimeos\MShop::create($context, 'product/lists/type'); |
|
83 | 83 | |
84 | - $search = $manager->createSearch()->setSlice( 0, 0x7fffffff ); |
|
85 | - $search->setConditions( $search->compare( '==', 'product.lists.type.domain', 'product' ) ); |
|
84 | + $search = $manager->createSearch()->setSlice(0, 0x7fffffff); |
|
85 | + $search->setConditions($search->compare('==', 'product.lists.type.domain', 'product')); |
|
86 | 86 | |
87 | - foreach( $manager->searchItems( $search ) as $item ) { |
|
87 | + foreach ($manager->searchItems($search) as $item) { |
|
88 | 88 | $this->listTypes[$item->getCode()] = $item->getCode(); |
89 | 89 | } |
90 | 90 | } |
91 | 91 | else |
92 | 92 | { |
93 | - $this->listTypes = array_flip( $this->listTypes ); |
|
93 | + $this->listTypes = array_flip($this->listTypes); |
|
94 | 94 | } |
95 | 95 | |
96 | - $this->cache = $this->getCache( 'product' ); |
|
96 | + $this->cache = $this->getCache('product'); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -104,47 +104,47 @@ discard block |
||
104 | 104 | * @param array $data List of CSV fields with position as key and data as value |
105 | 105 | * @return array List of data which has not been imported |
106 | 106 | */ |
107 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
107 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
108 | 108 | { |
109 | 109 | $context = $this->getContext(); |
110 | - $manager = \Aimeos\MShop::create( $context, 'product/lists' ); |
|
111 | - $separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" ); |
|
110 | + $manager = \Aimeos\MShop::create($context, 'product/lists'); |
|
111 | + $separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n"); |
|
112 | 112 | |
113 | - $listItems = $product->getListItems( 'product', null, null, false ); |
|
114 | - $this->cache->set( $product ); |
|
113 | + $listItems = $product->getListItems('product', null, null, false); |
|
114 | + $this->cache->set($product); |
|
115 | 115 | |
116 | - foreach( $this->getMappedChunk( $data, $this->getMapping() ) as $list ) |
|
116 | + foreach ($this->getMappedChunk($data, $this->getMapping()) as $list) |
|
117 | 117 | { |
118 | - if( $this->checkEntry( $list ) === false ) { |
|
118 | + if ($this->checkEntry($list) === false) { |
|
119 | 119 | continue; |
120 | 120 | } |
121 | 121 | |
122 | - $listtype = $this->getValue( $list, 'product.lists.type', 'default' ); |
|
122 | + $listtype = $this->getValue($list, 'product.lists.type', 'default'); |
|
123 | 123 | |
124 | - foreach( explode( $separator, $this->getValue( $list, 'product.code', '' ) ) as $code ) |
|
124 | + foreach (explode($separator, $this->getValue($list, 'product.code', '')) as $code) |
|
125 | 125 | { |
126 | - $code = trim( $code ); |
|
126 | + $code = trim($code); |
|
127 | 127 | |
128 | - if( ( $prodid = $this->cache->get( $code ) ) === null ) |
|
128 | + if (($prodid = $this->cache->get($code)) === null) |
|
129 | 129 | { |
130 | 130 | $msg = 'No product for code "%1$s" available when importing product with code "%2$s"'; |
131 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( $msg, $code, $product->getCode() ) ); |
|
131 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf($msg, $code, $product->getCode())); |
|
132 | 132 | } |
133 | 133 | |
134 | - if( ( $listItem = $product->getListItem( 'product', $listtype, $prodid ) ) === null ) { |
|
135 | - $listItem = $manager->createItem()->setType( $listtype ); |
|
134 | + if (($listItem = $product->getListItem('product', $listtype, $prodid)) === null) { |
|
135 | + $listItem = $manager->createItem()->setType($listtype); |
|
136 | 136 | } else { |
137 | - unset( $listItems[$listItem->getId()] ); |
|
137 | + unset($listItems[$listItem->getId()]); |
|
138 | 138 | } |
139 | 139 | |
140 | - $listItem = $listItem->fromArray( $list )->setRefId( $prodid ); |
|
141 | - $product->addListItem( 'product', $listItem ); |
|
140 | + $listItem = $listItem->fromArray($list)->setRefId($prodid); |
|
141 | + $product->addListItem('product', $listItem); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
145 | - $product->deleteListItems( $listItems ); |
|
145 | + $product->deleteListItems($listItems); |
|
146 | 146 | |
147 | - return $this->getObject()->process( $product, $data ); |
|
147 | + return $this->getObject()->process($product, $data); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | |
@@ -154,16 +154,16 @@ discard block |
||
154 | 154 | * @param array $list Associative list of key/value pairs from the mapping |
155 | 155 | * @return boolean True if valid, false if not |
156 | 156 | */ |
157 | - protected function checkEntry( array $list ) |
|
157 | + protected function checkEntry(array $list) |
|
158 | 158 | { |
159 | - if( $this->getValue( $list, 'product.code' ) === null ) { |
|
159 | + if ($this->getValue($list, 'product.code') === null) { |
|
160 | 160 | return false; |
161 | 161 | } |
162 | 162 | |
163 | - if( ( $type = $this->getValue( $list, 'product.lists.type' ) ) && !isset( $this->listTypes[$type] ) ) |
|
163 | + if (($type = $this->getValue($list, 'product.lists.type')) && !isset($this->listTypes[$type])) |
|
164 | 164 | { |
165 | - $msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'product list' ); |
|
166 | - throw new \Aimeos\Controller\Common\Exception( $msg ); |
|
165 | + $msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'product list'); |
|
166 | + throw new \Aimeos\Controller\Common\Exception($msg); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | return true; |
@@ -42,15 +42,15 @@ discard block |
||
42 | 42 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
43 | 43 | * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor |
44 | 44 | */ |
45 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
46 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null ) |
|
45 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
46 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null) |
|
47 | 47 | { |
48 | - parent::__construct( $context, $mapping, $object ); |
|
48 | + parent::__construct($context, $mapping, $object); |
|
49 | 49 | |
50 | - $manager = \Aimeos\MShop::create( $context, 'product/property/type' ); |
|
51 | - $search = $manager->createSearch()->setSlice( 0, 0x7fffffff ); |
|
50 | + $manager = \Aimeos\MShop::create($context, 'product/property/type'); |
|
51 | + $search = $manager->createSearch()->setSlice(0, 0x7fffffff); |
|
52 | 52 | |
53 | - foreach( $manager->searchItems( $search ) as $item ) { |
|
53 | + foreach ($manager->searchItems($search) as $item) { |
|
54 | 54 | $this->types[$item->getCode()] = $item->getCode(); |
55 | 55 | } |
56 | 56 | } |
@@ -63,45 +63,45 @@ discard block |
||
63 | 63 | * @param array $data List of CSV fields with position as key and data as value |
64 | 64 | * @return array List of data which hasn't been imported |
65 | 65 | */ |
66 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
66 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
67 | 67 | { |
68 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'product/property' ); |
|
68 | + $manager = \Aimeos\MShop::create($this->getContext(), 'product/property'); |
|
69 | 69 | |
70 | 70 | $propMap = []; |
71 | - $items = $product->getPropertyItems( null, false ); |
|
72 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
71 | + $items = $product->getPropertyItems(null, false); |
|
72 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
73 | 73 | |
74 | - foreach( $items as $item ) { |
|
75 | - $propMap[ $item->getValue() ][ $item->getType() ] = $item; |
|
74 | + foreach ($items as $item) { |
|
75 | + $propMap[$item->getValue()][$item->getType()] = $item; |
|
76 | 76 | } |
77 | 77 | |
78 | - foreach( $map as $list ) |
|
78 | + foreach ($map as $list) |
|
79 | 79 | { |
80 | - if( ( $value = $this->getValue( $list, 'product.property.value' ) ) === null ) { |
|
80 | + if (($value = $this->getValue($list, 'product.property.value')) === null) { |
|
81 | 81 | continue; |
82 | 82 | } |
83 | 83 | |
84 | - if( ( $type = $this->getValue( $list, 'product.property.type' ) ) && !isset( $this->types[$type] ) ) |
|
84 | + if (($type = $this->getValue($list, 'product.property.type')) && !isset($this->types[$type])) |
|
85 | 85 | { |
86 | - $msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'product property' ); |
|
87 | - throw new \Aimeos\Controller\Common\Exception( $msg ); |
|
86 | + $msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'product property'); |
|
87 | + throw new \Aimeos\Controller\Common\Exception($msg); |
|
88 | 88 | } |
89 | 89 | |
90 | - if( isset( $propMap[$value][$type] ) ) |
|
90 | + if (isset($propMap[$value][$type])) |
|
91 | 91 | { |
92 | 92 | $item = $propMap[$value][$type]; |
93 | - unset( $items[ $item->getId() ] ); |
|
93 | + unset($items[$item->getId()]); |
|
94 | 94 | } |
95 | 95 | else |
96 | 96 | { |
97 | - $item = $manager->createItem()->setType( $type ); |
|
97 | + $item = $manager->createItem()->setType($type); |
|
98 | 98 | } |
99 | 99 | |
100 | - $product->addPropertyItem( $item->fromArray( $list ) ); |
|
100 | + $product->addPropertyItem($item->fromArray($list)); |
|
101 | 101 | } |
102 | 102 | |
103 | - $product->deletePropertyItems( $items ); |
|
103 | + $product->deletePropertyItems($items); |
|
104 | 104 | |
105 | - return $this->getObject()->process( $product, $data ); |
|
105 | + return $this->getObject()->process($product, $data); |
|
106 | 106 | } |
107 | 107 | } |
@@ -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 |
@@ -68,26 +68,26 @@ discard block |
||
68 | 68 | * @see controller/common/product/import/csv/processor/text/listtypes |
69 | 69 | */ |
70 | 70 | $key = 'controller/common/product/import/csv/processor/catalog/listtypes'; |
71 | - $this->listTypes = $context->getConfig()->get( $key ); |
|
71 | + $this->listTypes = $context->getConfig()->get($key); |
|
72 | 72 | |
73 | - if( $this->listTypes === null ) |
|
73 | + if ($this->listTypes === null) |
|
74 | 74 | { |
75 | 75 | $this->listTypes = []; |
76 | - $manager = \Aimeos\MShop::create( $context, 'catalog/lists/type' ); |
|
76 | + $manager = \Aimeos\MShop::create($context, 'catalog/lists/type'); |
|
77 | 77 | |
78 | - $search = $manager->createSearch()->setSlice( 0, 0x7fffffff ); |
|
79 | - $search->setConditions( $search->compare( '==', 'catalog.lists.type.domain', 'product' ) ); |
|
78 | + $search = $manager->createSearch()->setSlice(0, 0x7fffffff); |
|
79 | + $search->setConditions($search->compare('==', 'catalog.lists.type.domain', 'product')); |
|
80 | 80 | |
81 | - foreach( $manager->searchItems( $search ) as $item ) { |
|
81 | + foreach ($manager->searchItems($search) as $item) { |
|
82 | 82 | $this->listTypes[$item->getCode()] = $item->getCode(); |
83 | 83 | } |
84 | 84 | } |
85 | 85 | else |
86 | 86 | { |
87 | - $this->listTypes = array_flip( $this->listTypes ); |
|
87 | + $this->listTypes = array_flip($this->listTypes); |
|
88 | 88 | } |
89 | 89 | |
90 | - $this->cache = $this->getCache( 'catalog' ); |
|
90 | + $this->cache = $this->getCache('catalog'); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | * @param array $data List of CSV fields with position as key and data as value |
99 | 99 | * @return array List of data which hasn't been imported |
100 | 100 | */ |
101 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
101 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
102 | 102 | { |
103 | 103 | $context = $this->getContext(); |
104 | - $manager = \Aimeos\MShop::create( $context, 'catalog' ); |
|
105 | - $listManager = \Aimeos\MShop::create( $context, 'catalog/lists' ); |
|
104 | + $manager = \Aimeos\MShop::create($context, 'catalog'); |
|
105 | + $listManager = \Aimeos\MShop::create($context, 'catalog/lists'); |
|
106 | 106 | |
107 | 107 | /** controller/common/product/import/csv/separator |
108 | 108 | * Single separator character for multiple entries in one field of the import file |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @category Developer |
123 | 123 | * @see controller/common/product/import/csv/domains |
124 | 124 | */ |
125 | - $separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" ); |
|
125 | + $separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n"); |
|
126 | 126 | |
127 | 127 | $manager->begin(); |
128 | 128 | |
@@ -130,57 +130,57 @@ discard block |
||
130 | 130 | { |
131 | 131 | $listMap = []; |
132 | 132 | $prodid = $product->getId(); |
133 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
134 | - $listItems = $this->getListItems( $prodid, $this->listTypes ); |
|
133 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
134 | + $listItems = $this->getListItems($prodid, $this->listTypes); |
|
135 | 135 | |
136 | - foreach( $listItems as $listItem ) { |
|
137 | - $listMap[ $listItem->getParentId() ][ $listItem->getType() ] = $listItem; |
|
136 | + foreach ($listItems as $listItem) { |
|
137 | + $listMap[$listItem->getParentId()][$listItem->getType()] = $listItem; |
|
138 | 138 | } |
139 | 139 | |
140 | - foreach( $map as $pos => $list ) |
|
140 | + foreach ($map as $pos => $list) |
|
141 | 141 | { |
142 | - if( $this->checkEntry( $list ) === false ) { |
|
142 | + if ($this->checkEntry($list) === false) { |
|
143 | 143 | continue; |
144 | 144 | } |
145 | 145 | |
146 | - $codes = explode( $separator, $this->getValue( $list, 'catalog.code', '' ) ); |
|
147 | - $listtype = $this->getValue( $list, 'catalog.lists.type', 'default' ); |
|
146 | + $codes = explode($separator, $this->getValue($list, 'catalog.code', '')); |
|
147 | + $listtype = $this->getValue($list, 'catalog.lists.type', 'default'); |
|
148 | 148 | |
149 | - foreach( $codes as $code ) |
|
149 | + foreach ($codes as $code) |
|
150 | 150 | { |
151 | - $code = trim( $code ); |
|
151 | + $code = trim($code); |
|
152 | 152 | |
153 | - if( ( $catid = $this->cache->get( $code ) ) === null ) |
|
153 | + if (($catid = $this->cache->get($code)) === null) |
|
154 | 154 | { |
155 | 155 | $msg = 'No category for code "%1$s" available when importing product with code "%2$s"'; |
156 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( $msg, $code, $product->getCode() ) ); |
|
156 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf($msg, $code, $product->getCode())); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | $list['catalog.lists.parentid'] = $catid; |
160 | 160 | $list['catalog.lists.refid'] = $prodid; |
161 | 161 | $list['catalog.lists.domain'] = 'product'; |
162 | 162 | |
163 | - if( isset( $listMap[$catid][$listtype] ) ) |
|
163 | + if (isset($listMap[$catid][$listtype])) |
|
164 | 164 | { |
165 | 165 | $listItem = $listMap[$catid][$listtype]; |
166 | - unset( $listItems[ $listItem->getId() ] ); |
|
166 | + unset($listItems[$listItem->getId()]); |
|
167 | 167 | } |
168 | 168 | else |
169 | 169 | { |
170 | - $listItem = $listManager->createItem()->setType( $listtype ); |
|
170 | + $listItem = $listManager->createItem()->setType($listtype); |
|
171 | 171 | } |
172 | 172 | |
173 | - $listItem = $listItem->setPosition( $pos++ )->fromArray( $list ); |
|
174 | - $listManager->saveItem( $listItem, false ); |
|
173 | + $listItem = $listItem->setPosition($pos++)->fromArray($list); |
|
174 | + $listManager->saveItem($listItem, false); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
178 | - $listManager->deleteItems( array_keys( $listItems ) ); |
|
179 | - $data = $this->getObject()->process( $product, $data ); |
|
178 | + $listManager->deleteItems(array_keys($listItems)); |
|
179 | + $data = $this->getObject()->process($product, $data); |
|
180 | 180 | |
181 | 181 | $manager->commit(); |
182 | 182 | } |
183 | - catch( \Exception $e ) |
|
183 | + catch (\Exception $e) |
|
184 | 184 | { |
185 | 185 | $manager->rollback(); |
186 | 186 | throw $e; |
@@ -197,13 +197,13 @@ discard block |
||
197 | 197 | * @param integer $pos Computed position of the list item in the associated list of items |
198 | 198 | * @return array Given associative list enriched by default values if they were not already set |
199 | 199 | */ |
200 | - protected function addListItemDefaults( array $list, $pos ) |
|
200 | + protected function addListItemDefaults(array $list, $pos) |
|
201 | 201 | { |
202 | - if( !isset( $list['catalog.lists.position'] ) ) { |
|
202 | + if (!isset($list['catalog.lists.position'])) { |
|
203 | 203 | $list['catalog.lists.position'] = $pos; |
204 | 204 | } |
205 | 205 | |
206 | - if( !isset( $list['catalog.lists.status'] ) ) { |
|
206 | + if (!isset($list['catalog.lists.status'])) { |
|
207 | 207 | $list['catalog.lists.status'] = 1; |
208 | 208 | } |
209 | 209 | |
@@ -217,16 +217,16 @@ discard block |
||
217 | 217 | * @param array $list Associative list of key/value pairs from the mapped data |
218 | 218 | * @return boolean True if the entry is valid, false if not |
219 | 219 | */ |
220 | - protected function checkEntry( array $list ) |
|
220 | + protected function checkEntry(array $list) |
|
221 | 221 | { |
222 | - if( $this->getValue( $list, 'catalog.code' ) === null ) { |
|
222 | + if ($this->getValue($list, 'catalog.code') === null) { |
|
223 | 223 | return false; |
224 | 224 | } |
225 | 225 | |
226 | - if( ( $type = $this->getValue( $list, 'catalog.lists.type' ) ) && !isset( $this->listTypes[$type] ) ) |
|
226 | + if (($type = $this->getValue($list, 'catalog.lists.type')) && !isset($this->listTypes[$type])) |
|
227 | 227 | { |
228 | - $msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'catalog list' ); |
|
229 | - throw new \Aimeos\Controller\Common\Exception( $msg ); |
|
228 | + $msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'catalog list'); |
|
229 | + throw new \Aimeos\Controller\Common\Exception($msg); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | return true; |
@@ -240,24 +240,24 @@ discard block |
||
240 | 240 | * @param array|null $types List of catalog list types |
241 | 241 | * @return array List of catalog list items |
242 | 242 | */ |
243 | - protected function getListItems( $prodid, $types ) |
|
243 | + protected function getListItems($prodid, $types) |
|
244 | 244 | { |
245 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'catalog/lists' ); |
|
245 | + $manager = \Aimeos\MShop::create($this->getContext(), 'catalog/lists'); |
|
246 | 246 | $search = $manager->createSearch(); |
247 | 247 | |
248 | 248 | $expr = array( |
249 | - $search->compare( '==', 'catalog.lists.domain', 'product' ), |
|
250 | - $search->compare( '==', 'catalog.lists.refid', $prodid ), |
|
249 | + $search->compare('==', 'catalog.lists.domain', 'product'), |
|
250 | + $search->compare('==', 'catalog.lists.refid', $prodid), |
|
251 | 251 | ); |
252 | 252 | |
253 | - if( $types !== null ) { |
|
254 | - $expr[] = $search->compare( '==', 'catalog.lists.type', $types ); |
|
253 | + if ($types !== null) { |
|
254 | + $expr[] = $search->compare('==', 'catalog.lists.type', $types); |
|
255 | 255 | } |
256 | 256 | |
257 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
258 | - $search->setSortations( array( $search->sort( '+', 'catalog.lists.position' ) ) ); |
|
259 | - $search->setSlice( 0, 0x7FFFFFFF ); |
|
257 | + $search->setConditions($search->combine('&&', $expr)); |
|
258 | + $search->setSortations(array($search->sort('+', 'catalog.lists.position'))); |
|
259 | + $search->setSlice(0, 0x7FFFFFFF); |
|
260 | 260 | |
261 | - return $manager->searchItems( $search ); |
|
261 | + return $manager->searchItems($search); |
|
262 | 262 | } |
263 | 263 | } |