@@ -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,63 +18,63 @@ 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 | $this->object = null; |
38 | 38 | |
39 | - if( file_exists( 'tmp/import.zip' ) ) { |
|
40 | - unlink( 'tmp/import.zip' ); |
|
39 | + if (file_exists('tmp/import.zip')) { |
|
40 | + unlink('tmp/import.zip'); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | 45 | public function testGetName() |
46 | 46 | { |
47 | - $this->assertEquals( 'Catalog import CSV', $this->object->getName() ); |
|
47 | + $this->assertEquals('Catalog import CSV', $this->object->getName()); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
51 | 51 | public function testGetDescription() |
52 | 52 | { |
53 | 53 | $text = 'Imports new and updates existing categories from CSV files'; |
54 | - $this->assertEquals( $text, $this->object->getDescription() ); |
|
54 | + $this->assertEquals($text, $this->object->getDescription()); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
58 | 58 | public function testRun() |
59 | 59 | { |
60 | - $catcodes = array( 'job_csv_test', 'job_csv_test2', 'job_csv_test3', 'job_csv_test4' ); |
|
61 | - $domains = array( 'media', 'text' ); |
|
60 | + $catcodes = array('job_csv_test', 'job_csv_test2', 'job_csv_test3', 'job_csv_test4'); |
|
61 | + $domains = array('media', 'text'); |
|
62 | 62 | |
63 | 63 | $convert = array( |
64 | 64 | 1 => 'Text/LatinUTF8', |
65 | 65 | ); |
66 | 66 | |
67 | - $this->context->getConfig()->set( 'controller/jobs/catalog/import/csv/converter', $convert ); |
|
67 | + $this->context->getConfig()->set('controller/jobs/catalog/import/csv/converter', $convert); |
|
68 | 68 | |
69 | 69 | $this->object->run(); |
70 | 70 | |
71 | - $tree = $this->get( 'job_csv_test', $domains ); |
|
72 | - $this->delete( $tree, $domains ); |
|
71 | + $tree = $this->get('job_csv_test', $domains); |
|
72 | + $this->delete($tree, $domains); |
|
73 | 73 | |
74 | - $this->assertEquals( 2, count( $tree->getListItems() ) ); |
|
74 | + $this->assertEquals(2, count($tree->getListItems())); |
|
75 | 75 | |
76 | - foreach( $tree->getChildren() as $node ) { |
|
77 | - $this->assertEquals( 2, count( $node->getListItems() ) ); |
|
76 | + foreach ($tree->getChildren() as $node) { |
|
77 | + $this->assertEquals(2, count($node->getListItems())); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | $this->object->run(); |
85 | 85 | $this->object->run(); |
86 | 86 | |
87 | - $tree = $this->get( 'job_csv_test', ['media', 'text'] ); |
|
88 | - $this->delete( $tree, ['media', 'text'] ); |
|
87 | + $tree = $this->get('job_csv_test', ['media', 'text']); |
|
88 | + $this->delete($tree, ['media', 'text']); |
|
89 | 89 | |
90 | - $this->assertEquals( 2, count( $tree->getListItems() ) ); |
|
90 | + $this->assertEquals(2, count($tree->getListItems())); |
|
91 | 91 | |
92 | - foreach( $tree->getChildren() as $node ) { |
|
93 | - $this->assertEquals( 2, count( $node->getListItems() ) ); |
|
92 | + foreach ($tree->getChildren() as $node) { |
|
93 | + $this->assertEquals(2, count($node->getListItems())); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
@@ -98,18 +98,18 @@ discard block |
||
98 | 98 | public function testRunPosition() |
99 | 99 | { |
100 | 100 | $config = $this->context->getConfig(); |
101 | - $mapping = $config->set( 'controller/jobs/catalog/import/csv/mapping', [] ); |
|
102 | - $mapping['item'] = array( 0 => 'catalog.label', 1 => 'catalog.code', 2 => 'catalog.parent' ); |
|
101 | + $mapping = $config->set('controller/jobs/catalog/import/csv/mapping', []); |
|
102 | + $mapping['item'] = array(0 => 'catalog.label', 1 => 'catalog.code', 2 => 'catalog.parent'); |
|
103 | 103 | |
104 | - $config->set( 'controller/jobs/catalog/import/csv/mapping', $mapping ); |
|
105 | - $config->set( 'controller/jobs/catalog/import/csv/location', __DIR__ . '/_testfiles/position' ); |
|
104 | + $config->set('controller/jobs/catalog/import/csv/mapping', $mapping); |
|
105 | + $config->set('controller/jobs/catalog/import/csv/location', __DIR__ . '/_testfiles/position'); |
|
106 | 106 | |
107 | 107 | $this->object->run(); |
108 | 108 | |
109 | - $tree = $this->get( 'job_csv_test' ); |
|
110 | - $this->delete( $tree ); |
|
109 | + $tree = $this->get('job_csv_test'); |
|
110 | + $this->delete($tree); |
|
111 | 111 | |
112 | - $this->assertEquals( 1, count( $tree->getChildren() ) ); |
|
112 | + $this->assertEquals(1, count($tree->getChildren())); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | ), |
134 | 134 | ); |
135 | 135 | |
136 | - $this->context->getConfig()->set( 'controller/jobs/catalog/import/csv/mapping', $mapping ); |
|
136 | + $this->context->getConfig()->set('controller/jobs/catalog/import/csv/mapping', $mapping); |
|
137 | 137 | |
138 | 138 | $this->object->run(); |
139 | 139 | |
140 | - $tree = $this->get( 'job_csv_test' ); |
|
141 | - $this->delete( $tree ); |
|
140 | + $tree = $this->get('job_csv_test'); |
|
141 | + $this->delete($tree); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | ), |
151 | 151 | ); |
152 | 152 | |
153 | - $this->context->getConfig()->set( 'controller/jobs/catalog/import/csv/mapping', $mapping ); |
|
153 | + $this->context->getConfig()->set('controller/jobs/catalog/import/csv/mapping', $mapping); |
|
154 | 154 | |
155 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
155 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
156 | 156 | $this->object->run(); |
157 | 157 | } |
158 | 158 | |
@@ -176,15 +176,15 @@ discard block |
||
176 | 176 | ), |
177 | 177 | ); |
178 | 178 | |
179 | - $this->context->getConfig()->set( 'controller/jobs/catalog/import/csv/mapping', $mapping ); |
|
179 | + $this->context->getConfig()->set('controller/jobs/catalog/import/csv/mapping', $mapping); |
|
180 | 180 | |
181 | 181 | $config = $this->context->getConfig(); |
182 | - $config->set( 'controller/jobs/catalog/import/csv/skip-lines', 0 ); |
|
183 | - $config->set( 'controller/jobs/catalog/import/csv/location', __DIR__ . '/_testfiles/invalid' ); |
|
182 | + $config->set('controller/jobs/catalog/import/csv/skip-lines', 0); |
|
183 | + $config->set('controller/jobs/catalog/import/csv/location', __DIR__ . '/_testfiles/invalid'); |
|
184 | 184 | |
185 | - $this->object = new \Aimeos\Controller\Jobs\Catalog\Import\Csv\Standard( $this->context, $this->aimeos ); |
|
185 | + $this->object = new \Aimeos\Controller\Jobs\Catalog\Import\Csv\Standard($this->context, $this->aimeos); |
|
186 | 186 | |
187 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
187 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
188 | 188 | $this->object->run(); |
189 | 189 | } |
190 | 190 | |
@@ -192,65 +192,65 @@ discard block |
||
192 | 192 | public function testRunBackup() |
193 | 193 | { |
194 | 194 | $config = $this->context->getConfig(); |
195 | - $config->set( 'controller/jobs/catalog/import/csv/container/type', 'Zip' ); |
|
196 | - $config->set( 'controller/jobs/catalog/import/csv/location', 'tmp/import.zip' ); |
|
197 | - $config->set( 'controller/jobs/catalog/import/csv/backup', 'tmp/test-%Y-%m-%d.zip' ); |
|
195 | + $config->set('controller/jobs/catalog/import/csv/container/type', 'Zip'); |
|
196 | + $config->set('controller/jobs/catalog/import/csv/location', 'tmp/import.zip'); |
|
197 | + $config->set('controller/jobs/catalog/import/csv/backup', 'tmp/test-%Y-%m-%d.zip'); |
|
198 | 198 | |
199 | - if( copy( __DIR__ . '/_testfiles/import.zip', 'tmp/import.zip' ) === false ) { |
|
200 | - throw new \RuntimeException( 'Unable to copy test file' ); |
|
199 | + if (copy(__DIR__ . '/_testfiles/import.zip', 'tmp/import.zip') === false) { |
|
200 | + throw new \RuntimeException('Unable to copy test file'); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | $this->object->run(); |
204 | 204 | |
205 | - $filename = strftime( 'tmp/test-%Y-%m-%d.zip' ); |
|
206 | - $this->assertTrue( file_exists( $filename ) ); |
|
205 | + $filename = strftime('tmp/test-%Y-%m-%d.zip'); |
|
206 | + $this->assertTrue(file_exists($filename)); |
|
207 | 207 | |
208 | - unlink( $filename ); |
|
208 | + unlink($filename); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
212 | 212 | public function testRunBackupInvalid() |
213 | 213 | { |
214 | 214 | $config = $this->context->getConfig(); |
215 | - $config->set( 'controller/jobs/catalog/import/csv/container/type', 'Zip' ); |
|
216 | - $config->set( 'controller/jobs/catalog/import/csv/location', 'tmp/import.zip' ); |
|
217 | - $config->set( 'controller/jobs/catalog/import/csv/backup', 'tmp/notexist/import.zip' ); |
|
215 | + $config->set('controller/jobs/catalog/import/csv/container/type', 'Zip'); |
|
216 | + $config->set('controller/jobs/catalog/import/csv/location', 'tmp/import.zip'); |
|
217 | + $config->set('controller/jobs/catalog/import/csv/backup', 'tmp/notexist/import.zip'); |
|
218 | 218 | |
219 | - if( copy( __DIR__ . '/_testfiles/import.zip', 'tmp/import.zip' ) === false ) { |
|
220 | - throw new \RuntimeException( 'Unable to copy test file' ); |
|
219 | + if (copy(__DIR__ . '/_testfiles/import.zip', 'tmp/import.zip') === false) { |
|
220 | + throw new \RuntimeException('Unable to copy test file'); |
|
221 | 221 | } |
222 | 222 | |
223 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
223 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
224 | 224 | $this->object->run(); |
225 | 225 | } |
226 | 226 | |
227 | 227 | |
228 | - protected function delete( \Aimeos\MShop\Catalog\Item\Iface $tree, array $domains = [] ) |
|
228 | + protected function delete(\Aimeos\MShop\Catalog\Item\Iface $tree, array $domains = []) |
|
229 | 229 | { |
230 | - $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::create( $this->context ); |
|
230 | + $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::create($this->context); |
|
231 | 231 | |
232 | - foreach( $domains as $domain ) |
|
232 | + foreach ($domains as $domain) |
|
233 | 233 | { |
234 | - $manager = \Aimeos\MShop::create( $this->context, $domain ); |
|
234 | + $manager = \Aimeos\MShop::create($this->context, $domain); |
|
235 | 235 | |
236 | - foreach( $tree->getListItems( $domain ) as $listItem ) { |
|
237 | - $manager->deleteItem( $listItem->getRefItem()->getId() ); |
|
236 | + foreach ($tree->getListItems($domain) as $listItem) { |
|
237 | + $manager->deleteItem($listItem->getRefItem()->getId()); |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 | |
241 | - foreach( $tree->getChildren() as $node ) { |
|
242 | - $this->delete( $node, $domains ); |
|
241 | + foreach ($tree->getChildren() as $node) { |
|
242 | + $this->delete($node, $domains); |
|
243 | 243 | } |
244 | 244 | |
245 | - $catalogManager->deleteItem( $tree->getId() ); |
|
245 | + $catalogManager->deleteItem($tree->getId()); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | |
249 | - protected function get( $catcode, array $domains = [] ) |
|
249 | + protected function get($catcode, array $domains = []) |
|
250 | 250 | { |
251 | - $manager = \Aimeos\MShop\Catalog\Manager\Factory::create( $this->context ); |
|
252 | - $root = $manager->findItem( $catcode ); |
|
251 | + $manager = \Aimeos\MShop\Catalog\Manager\Factory::create($this->context); |
|
252 | + $root = $manager->findItem($catcode); |
|
253 | 253 | |
254 | - return $manager->getTree( $root->getId(), $domains, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ); |
|
254 | + return $manager->getTree($root->getId(), $domains, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE); |
|
255 | 255 | } |
256 | 256 | } |
257 | 257 | \ 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::create( $this->context, $aimeos, 'Standard' ); |
|
65 | + $cntl = \Aimeos\Controller\Jobs\Product\Import\Csv\Factory::create($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 |
@@ -27,14 +27,14 @@ discard block |
||
27 | 27 | * @param array $data Associative list of product codes and lists of CSV field indexes and their data |
28 | 28 | * @return array Associative list of CSV field indexes and their converted data |
29 | 29 | */ |
30 | - protected function convertData( array $convlist, array $data ) |
|
30 | + protected function convertData(array $convlist, array $data) |
|
31 | 31 | { |
32 | - foreach( $convlist as $idx => $converter ) |
|
32 | + foreach ($convlist as $idx => $converter) |
|
33 | 33 | { |
34 | - foreach( $data as $code => $list ) |
|
34 | + foreach ($data as $code => $list) |
|
35 | 35 | { |
36 | - if( isset( $list[$idx] ) ) { |
|
37 | - $data[$code][$idx] = $converter->translate( $list[$idx] ); |
|
36 | + if (isset($list[$idx])) { |
|
37 | + $data[$code][$idx] = $converter->translate($list[$idx]); |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 | } |
@@ -50,36 +50,36 @@ discard block |
||
50 | 50 | * @param string|null Name of the cache implementation |
51 | 51 | * @return \Aimeos\Controller\Common\Product\Import\Csv\Cache\Iface Cache object |
52 | 52 | */ |
53 | - protected function getCache( $type, $name = null ) |
|
53 | + protected function getCache($type, $name = null) |
|
54 | 54 | { |
55 | 55 | $context = $this->getContext(); |
56 | 56 | $config = $context->getConfig(); |
57 | 57 | |
58 | - if( ctype_alnum( $type ) === false ) |
|
58 | + if (ctype_alnum($type) === false) |
|
59 | 59 | { |
60 | 60 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . $type : '<not a string>'; |
61 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
61 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
62 | 62 | } |
63 | 63 | |
64 | - if( $name === null ) { |
|
65 | - $name = $config->get( 'controller/common/product/import/csv/cache/' . $type . '/name', 'Standard' ); |
|
64 | + if ($name === null) { |
|
65 | + $name = $config->get('controller/common/product/import/csv/cache/' . $type . '/name', 'Standard'); |
|
66 | 66 | } |
67 | 67 | |
68 | - if( ctype_alnum( $name ) === false ) |
|
68 | + if (ctype_alnum($name) === false) |
|
69 | 69 | { |
70 | 70 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . $type . '\\' . $name : '<not a string>'; |
71 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
71 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
72 | 72 | } |
73 | 73 | |
74 | - $classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . ucfirst( $type ) . '\\' . $name; |
|
74 | + $classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . ucfirst($type) . '\\' . $name; |
|
75 | 75 | |
76 | - if( class_exists( $classname ) === false ) { |
|
77 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) ); |
|
76 | + if (class_exists($classname) === false) { |
|
77 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname)); |
|
78 | 78 | } |
79 | 79 | |
80 | - $object = new $classname( $context ); |
|
80 | + $object = new $classname($context); |
|
81 | 81 | |
82 | - \Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\Iface', $object ); |
|
82 | + \Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\Iface', $object); |
|
83 | 83 | |
84 | 84 | return $object; |
85 | 85 | } |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | * @param array $convmap List of converter names for the values at the position in the CSV file |
92 | 92 | * @return array Associative list of positions and converter objects |
93 | 93 | */ |
94 | - protected function getConverterList( array $convmap ) |
|
94 | + protected function getConverterList(array $convmap) |
|
95 | 95 | { |
96 | 96 | $convlist = []; |
97 | 97 | |
98 | - foreach( $convmap as $idx => $name ) { |
|
99 | - $convlist[$idx] = \Aimeos\MW\Convert\Factory::createConverter( $name ); |
|
98 | + foreach ($convmap as $idx => $name) { |
|
99 | + $convlist[$idx] = \Aimeos\MW\Convert\Factory::createConverter($name); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | return $convlist; |
@@ -111,15 +111,15 @@ discard block |
||
111 | 111 | * @param integer $codePos Column position which contains the unique product code (starting from 0) |
112 | 112 | * @return array List of arrays with product codes as keys and list of values from the CSV file |
113 | 113 | */ |
114 | - protected function getData( \Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos ) |
|
114 | + protected function getData(\Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos) |
|
115 | 115 | { |
116 | 116 | $count = 0; |
117 | 117 | $data = []; |
118 | 118 | |
119 | - while( $content->valid() && $count++ < $maxcnt ) |
|
119 | + while ($content->valid() && $count++ < $maxcnt) |
|
120 | 120 | { |
121 | 121 | $row = $content->current(); |
122 | - $data[ $row[$codePos] ] = $row; |
|
122 | + $data[$row[$codePos]] = $row; |
|
123 | 123 | $content->next(); |
124 | 124 | } |
125 | 125 | |
@@ -218,21 +218,21 @@ discard block |
||
218 | 218 | * @param array $mapping List of domain item keys with the CSV field position as key |
219 | 219 | * @return array List of associative arrays containing the chunked properties |
220 | 220 | */ |
221 | - protected function getMappedChunk( array &$data, array $mapping ) |
|
221 | + protected function getMappedChunk(array &$data, array $mapping) |
|
222 | 222 | { |
223 | 223 | $idx = 0; |
224 | 224 | $map = []; |
225 | 225 | |
226 | - foreach( $mapping as $pos => $key ) |
|
226 | + foreach ($mapping as $pos => $key) |
|
227 | 227 | { |
228 | - if( isset( $map[$idx][$key] ) ) { |
|
228 | + if (isset($map[$idx][$key])) { |
|
229 | 229 | $idx++; |
230 | 230 | } |
231 | 231 | |
232 | - if( isset( $data[$pos] ) ) |
|
232 | + if (isset($data[$pos])) |
|
233 | 233 | { |
234 | 234 | $map[$idx][$key] = $data[$pos]; |
235 | - unset( $data[$pos] ); |
|
235 | + unset($data[$pos]); |
|
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
@@ -246,37 +246,37 @@ discard block |
||
246 | 246 | * @param array $mappings Associative list of processor types as keys and index/data mappings as values |
247 | 247 | * @return \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface Processor object |
248 | 248 | */ |
249 | - protected function getProcessors( array $mappings ) |
|
249 | + protected function getProcessors(array $mappings) |
|
250 | 250 | { |
251 | 251 | $context = $this->getContext(); |
252 | 252 | $config = $context->getConfig(); |
253 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done( $context, [] ); |
|
253 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done($context, []); |
|
254 | 254 | |
255 | - foreach( $mappings as $type => $mapping ) |
|
255 | + foreach ($mappings as $type => $mapping) |
|
256 | 256 | { |
257 | - if( ctype_alnum( $type ) === false ) |
|
257 | + if (ctype_alnum($type) === false) |
|
258 | 258 | { |
259 | 259 | $classname = is_string($type) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . $type : '<not a string>'; |
260 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
260 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
261 | 261 | } |
262 | 262 | |
263 | - $name = $config->get( 'controller/common/product/import/csv/processor/' . $type . '/name', 'Standard' ); |
|
263 | + $name = $config->get('controller/common/product/import/csv/processor/' . $type . '/name', 'Standard'); |
|
264 | 264 | |
265 | - if( ctype_alnum( $name ) === false ) |
|
265 | + if (ctype_alnum($name) === false) |
|
266 | 266 | { |
267 | 267 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . $type . '\\' . $name : '<not a string>'; |
268 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
268 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
269 | 269 | } |
270 | 270 | |
271 | - $classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . ucfirst( $type ) . '\\' . $name; |
|
271 | + $classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . ucfirst($type) . '\\' . $name; |
|
272 | 272 | |
273 | - if( class_exists( $classname ) === false ) { |
|
274 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) ); |
|
273 | + if (class_exists($classname) === false) { |
|
274 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname)); |
|
275 | 275 | } |
276 | 276 | |
277 | - $object = new $classname( $context, $mapping, $object ); |
|
277 | + $object = new $classname($context, $mapping, $object); |
|
278 | 278 | |
279 | - \Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\Iface', $object ); |
|
279 | + \Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\Iface', $object); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | return $object; |
@@ -290,17 +290,17 @@ discard block |
||
290 | 290 | * @param array $domains List of domains whose items should be fetched too |
291 | 291 | * @return array Associative list of product codes as key and product items as value |
292 | 292 | */ |
293 | - protected function getProducts( array $codes, array $domains ) |
|
293 | + protected function getProducts(array $codes, array $domains) |
|
294 | 294 | { |
295 | 295 | $result = []; |
296 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'product' ); |
|
296 | + $manager = \Aimeos\MShop::create($this->getContext(), 'product'); |
|
297 | 297 | |
298 | 298 | $search = $manager->createSearch(); |
299 | - $search->setConditions( $search->compare( '==', 'product.code', $codes ) ); |
|
300 | - $search->setSlice( 0, count( $codes ) ); |
|
299 | + $search->setConditions($search->compare('==', 'product.code', $codes)); |
|
300 | + $search->setSlice(0, count($codes)); |
|
301 | 301 | |
302 | - foreach( $manager->searchItems( $search, $domains ) as $item ) { |
|
303 | - $result[ $item->getCode() ] = $item; |
|
302 | + foreach ($manager->searchItems($search, $domains) as $item) { |
|
303 | + $result[$item->getCode()] = $item; |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | return $result; |
@@ -40,9 +40,9 @@ 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 | 47 | $config = $context->getConfig(); |
48 | 48 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @since 2018.04 |
58 | 58 | * @category Developer |
59 | 59 | */ |
60 | - $this->groupIds = (array) $config->get( 'controller/common/subscription/process/processor/cgroup/groupids', [] ); |
|
60 | + $this->groupIds = (array) $config->get('controller/common/subscription/process/processor/cgroup/groupids', []); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
@@ -66,22 +66,22 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @param \Aimeos\MShop\Subscription\Item\Iface $subscription Subscription item |
68 | 68 | */ |
69 | - public function begin( \Aimeos\MShop\Subscription\Item\Iface $subscription ) |
|
69 | + public function begin(\Aimeos\MShop\Subscription\Item\Iface $subscription) |
|
70 | 70 | { |
71 | - if( empty( $this->groupIds ) ) { |
|
71 | + if (empty($this->groupIds)) { |
|
72 | 72 | return; |
73 | 73 | } |
74 | 74 | |
75 | 75 | $context = $this->getContext(); |
76 | 76 | |
77 | - $manager = \Aimeos\MShop::create( $context, 'customer' ); |
|
78 | - $baseManager = \Aimeos\MShop::create( $context, 'order/base' ); |
|
77 | + $manager = \Aimeos\MShop::create($context, 'customer'); |
|
78 | + $baseManager = \Aimeos\MShop::create($context, 'order/base'); |
|
79 | 79 | |
80 | - $baseItem = $baseManager->getItem( $subscription->getOrderBaseId() ); |
|
81 | - $item = $manager->getItem( $baseItem->getCustomerId(), ['customer/group'] ); |
|
80 | + $baseItem = $baseManager->getItem($subscription->getOrderBaseId()); |
|
81 | + $item = $manager->getItem($baseItem->getCustomerId(), ['customer/group']); |
|
82 | 82 | |
83 | - $item->setGroups( array_unique( array_merge( $item->getGroups(), $this->groupIds ) ) ); |
|
84 | - $manager->saveItem( $item ); |
|
83 | + $item->setGroups(array_unique(array_merge($item->getGroups(), $this->groupIds))); |
|
84 | + $manager->saveItem($item); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -90,21 +90,21 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @param \Aimeos\MShop\Subscription\Item\Iface $subscription Subscription item |
92 | 92 | */ |
93 | - public function end( \Aimeos\MShop\Subscription\Item\Iface $subscription ) |
|
93 | + public function end(\Aimeos\MShop\Subscription\Item\Iface $subscription) |
|
94 | 94 | { |
95 | - if( empty( $this->groupIds ) ) { |
|
95 | + if (empty($this->groupIds)) { |
|
96 | 96 | return; |
97 | 97 | } |
98 | 98 | |
99 | 99 | $context = $this->getContext(); |
100 | 100 | |
101 | - $manager = \Aimeos\MShop::create( $context, 'customer' ); |
|
102 | - $baseManager = \Aimeos\MShop::create( $context, 'order/base' ); |
|
101 | + $manager = \Aimeos\MShop::create($context, 'customer'); |
|
102 | + $baseManager = \Aimeos\MShop::create($context, 'order/base'); |
|
103 | 103 | |
104 | - $baseItem = $baseManager->getItem( $subscription->getOrderBaseId() ); |
|
105 | - $item = $manager->getItem( $baseItem->getCustomerId(), ['customer/group'] ); |
|
104 | + $baseItem = $baseManager->getItem($subscription->getOrderBaseId()); |
|
105 | + $item = $manager->getItem($baseItem->getCustomerId(), ['customer/group']); |
|
106 | 106 | |
107 | - $item->setGroups( array_diff( $item->getGroups(), $this->groupIds ) ); |
|
108 | - $manager->saveItem( $item ); |
|
107 | + $item->setGroups(array_diff($item->getGroups(), $this->groupIds)); |
|
108 | + $manager->saveItem($item); |
|
109 | 109 | } |
110 | 110 | } |
@@ -40,20 +40,20 @@ |
||
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\Coupon\Item\Code\Iface $item, array $data ) |
|
43 | + public function process(\Aimeos\MShop\Coupon\Item\Code\Iface $item, array $data) |
|
44 | 44 | { |
45 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'coupon/code' ); |
|
46 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
45 | + $manager = \Aimeos\MShop::create($this->getContext(), 'coupon/code'); |
|
46 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
47 | 47 | |
48 | - foreach( $map as $list ) |
|
48 | + foreach ($map as $list) |
|
49 | 49 | { |
50 | - if( trim( $list['coupon.code.code'] ) == '' ) { |
|
50 | + if (trim($list['coupon.code.code']) == '') { |
|
51 | 51 | continue; |
52 | 52 | } |
53 | 53 | |
54 | - $item = $manager->saveItem( $item->fromArray( $list ) ); |
|
54 | + $item = $manager->saveItem($item->fromArray($list)); |
|
55 | 55 | } |
56 | 56 | |
57 | - return $this->getObject()->process( $item, $data ); |
|
57 | + return $this->getObject()->process($item, $data); |
|
58 | 58 | } |
59 | 59 | } |
@@ -26,17 +26,17 @@ discard block |
||
26 | 26 | * @param array $codes List of coupon codes |
27 | 27 | * @return array Associative list of coupon codes as key and coupon code items as value |
28 | 28 | */ |
29 | - protected function getCouponCodeItems( array $codes ) |
|
29 | + protected function getCouponCodeItems(array $codes) |
|
30 | 30 | { |
31 | 31 | $result = []; |
32 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'coupon/code' ); |
|
32 | + $manager = \Aimeos\MShop::create($this->getContext(), 'coupon/code'); |
|
33 | 33 | |
34 | 34 | $search = $manager->createSearch(); |
35 | - $search->setConditions( $search->compare( '==', 'coupon.code.code', $codes ) ); |
|
36 | - $search->setSlice( 0, count( $codes ) ); |
|
35 | + $search->setConditions($search->compare('==', 'coupon.code.code', $codes)); |
|
36 | + $search->setSlice(0, count($codes)); |
|
37 | 37 | |
38 | - foreach( $manager->searchItems( $search ) as $item ) { |
|
39 | - $result[ $item->getCode() ] = $item; |
|
38 | + foreach ($manager->searchItems($search) as $item) { |
|
39 | + $result[$item->getCode()] = $item; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | return $result; |
@@ -51,15 +51,15 @@ discard block |
||
51 | 51 | * @param integer $codePos Column position which contains the unique coupon code (starting from 0) |
52 | 52 | * @return array List of arrays with coupon codes as keys and list of values from the CSV file |
53 | 53 | */ |
54 | - protected function getData( \Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos ) |
|
54 | + protected function getData(\Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos) |
|
55 | 55 | { |
56 | 56 | $count = 0; |
57 | 57 | $data = []; |
58 | 58 | |
59 | - while( $content->valid() && $count++ < $maxcnt ) |
|
59 | + while ($content->valid() && $count++ < $maxcnt) |
|
60 | 60 | { |
61 | 61 | $row = $content->current(); |
62 | - $data[ $row[$codePos] ] = $row; |
|
62 | + $data[$row[$codePos]] = $row; |
|
63 | 63 | $content->next(); |
64 | 64 | } |
65 | 65 | |
@@ -98,21 +98,21 @@ discard block |
||
98 | 98 | * @param array $mapping List of domain item keys with the CSV field position as key |
99 | 99 | * @return array List of associative arrays containing the chunked properties |
100 | 100 | */ |
101 | - protected function getMappedChunk( array &$data, array $mapping ) |
|
101 | + protected function getMappedChunk(array &$data, array $mapping) |
|
102 | 102 | { |
103 | 103 | $idx = 0; |
104 | 104 | $map = []; |
105 | 105 | |
106 | - foreach( $mapping as $pos => $key ) |
|
106 | + foreach ($mapping as $pos => $key) |
|
107 | 107 | { |
108 | - if( isset( $map[$idx][$key] ) ) { |
|
108 | + if (isset($map[$idx][$key])) { |
|
109 | 109 | $idx++; |
110 | 110 | } |
111 | 111 | |
112 | - if( isset( $data[$pos] ) ) |
|
112 | + if (isset($data[$pos])) |
|
113 | 113 | { |
114 | 114 | $map[$idx][$key] = $data[$pos]; |
115 | - unset( $data[$pos] ); |
|
115 | + unset($data[$pos]); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
@@ -126,37 +126,37 @@ discard block |
||
126 | 126 | * @param array $mappings Associative list of processor types as keys and index/data mappings as values |
127 | 127 | * @return \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface Processor object |
128 | 128 | */ |
129 | - protected function getProcessors( array $mappings ) |
|
129 | + protected function getProcessors(array $mappings) |
|
130 | 130 | { |
131 | 131 | $context = $this->getContext(); |
132 | 132 | $config = $context->getConfig(); |
133 | - $object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Done( $context, [] ); |
|
133 | + $object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Done($context, []); |
|
134 | 134 | |
135 | - foreach( $mappings as $type => $mapping ) |
|
135 | + foreach ($mappings as $type => $mapping) |
|
136 | 136 | { |
137 | - if( ctype_alnum( $type ) === false ) |
|
137 | + if (ctype_alnum($type) === false) |
|
138 | 138 | { |
139 | 139 | $classname = is_string($type) ? '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . $type : '<not a string>'; |
140 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
140 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
141 | 141 | } |
142 | 142 | |
143 | - $name = $config->get( 'controller/common/coupon/import/csv/processor/' . $type . '/name', 'Standard' ); |
|
143 | + $name = $config->get('controller/common/coupon/import/csv/processor/' . $type . '/name', 'Standard'); |
|
144 | 144 | |
145 | - if( ctype_alnum( $name ) === false ) |
|
145 | + if (ctype_alnum($name) === false) |
|
146 | 146 | { |
147 | 147 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . $type . '\\' . $name : '<not a string>'; |
148 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
148 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
149 | 149 | } |
150 | 150 | |
151 | - $classname = '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . ucfirst( $type ) . '\\' . $name; |
|
151 | + $classname = '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . ucfirst($type) . '\\' . $name; |
|
152 | 152 | |
153 | - if( class_exists( $classname ) === false ) { |
|
154 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) ); |
|
153 | + if (class_exists($classname) === false) { |
|
154 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname)); |
|
155 | 155 | } |
156 | 156 | |
157 | - $object = new $classname( $context, $mapping, $object ); |
|
157 | + $object = new $classname($context, $mapping, $object); |
|
158 | 158 | |
159 | - \Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\Iface', $object ); |
|
159 | + \Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\Iface', $object); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | return $object; |