@@ -17,16 +17,16 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | protected function setUp() |
| 19 | 19 | { |
| 20 | - \Aimeos\MShop\Factory::setCache( true ); |
|
| 20 | + \Aimeos\MShop\Factory::setCache(true); |
|
| 21 | 21 | |
| 22 | 22 | $this->context = \TestHelperCntl::getContext(); |
| 23 | - $this->endpoint = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done( $this->context, [] ); |
|
| 23 | + $this->endpoint = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done($this->context, []); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | protected function tearDown() |
| 28 | 28 | { |
| 29 | - \Aimeos\MShop\Factory::setCache( false ); |
|
| 29 | + \Aimeos\MShop\Factory::setCache(false); |
|
| 30 | 30 | \Aimeos\MShop\Factory::clear(); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -57,33 +57,33 @@ discard block |
||
| 57 | 57 | 8 => 1, |
| 58 | 58 | ); |
| 59 | 59 | |
| 60 | - $product = $this->create( 'job_csv_test' ); |
|
| 60 | + $product = $this->create('job_csv_test'); |
|
| 61 | 61 | |
| 62 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint ); |
|
| 63 | - $object->process( $product, $data ); |
|
| 62 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint); |
|
| 63 | + $object->process($product, $data); |
|
| 64 | 64 | |
| 65 | 65 | |
| 66 | 66 | $listItems = $product->getListItems(); |
| 67 | - $listItem = reset( $listItems ); |
|
| 67 | + $listItem = reset($listItems); |
|
| 68 | 68 | |
| 69 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem ); |
|
| 70 | - $this->assertEquals( 1, count( $listItems ) ); |
|
| 69 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem); |
|
| 70 | + $this->assertEquals(1, count($listItems)); |
|
| 71 | 71 | |
| 72 | - $this->assertEquals( 1, $listItem->getStatus() ); |
|
| 73 | - $this->assertEquals( 0, $listItem->getPosition() ); |
|
| 74 | - $this->assertEquals( 'default', $listItem->getType() ); |
|
| 72 | + $this->assertEquals(1, $listItem->getStatus()); |
|
| 73 | + $this->assertEquals(0, $listItem->getPosition()); |
|
| 74 | + $this->assertEquals('default', $listItem->getType()); |
|
| 75 | 75 | |
| 76 | 76 | $refItem = $listItem->getRefItem(); |
| 77 | 77 | |
| 78 | - $this->assertEquals( 1, $refItem->getStatus() ); |
|
| 79 | - $this->assertEquals( 'default', $refItem->getType() ); |
|
| 80 | - $this->assertEquals( 'EUR 1.00', $refItem->getLabel() ); |
|
| 81 | - $this->assertEquals( 5, $refItem->getQuantity() ); |
|
| 82 | - $this->assertEquals( '1.00', $refItem->getValue() ); |
|
| 83 | - $this->assertEquals( '0.20', $refItem->getCosts() ); |
|
| 84 | - $this->assertEquals( '0.10', $refItem->getRebate() ); |
|
| 85 | - $this->assertEquals( '20.00', $refItem->getTaxrate() ); |
|
| 86 | - $this->assertEquals( 1, $refItem->getStatus() ); |
|
| 78 | + $this->assertEquals(1, $refItem->getStatus()); |
|
| 79 | + $this->assertEquals('default', $refItem->getType()); |
|
| 80 | + $this->assertEquals('EUR 1.00', $refItem->getLabel()); |
|
| 81 | + $this->assertEquals(5, $refItem->getQuantity()); |
|
| 82 | + $this->assertEquals('1.00', $refItem->getValue()); |
|
| 83 | + $this->assertEquals('0.20', $refItem->getCosts()); |
|
| 84 | + $this->assertEquals('0.10', $refItem->getRebate()); |
|
| 85 | + $this->assertEquals('20.00', $refItem->getTaxrate()); |
|
| 86 | + $this->assertEquals(1, $refItem->getStatus()); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | |
@@ -111,21 +111,21 @@ discard block |
||
| 111 | 111 | 7 => '4.00', |
| 112 | 112 | ); |
| 113 | 113 | |
| 114 | - $product = $this->create( 'job_csv_test' ); |
|
| 114 | + $product = $this->create('job_csv_test'); |
|
| 115 | 115 | |
| 116 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint ); |
|
| 117 | - $object->process( $product, $data ); |
|
| 116 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint); |
|
| 117 | + $object->process($product, $data); |
|
| 118 | 118 | |
| 119 | 119 | |
| 120 | 120 | $pos = 0; |
| 121 | 121 | $listItems = $product->getListItems(); |
| 122 | 122 | |
| 123 | - $this->assertEquals( 4, count( $listItems ) ); |
|
| 123 | + $this->assertEquals(4, count($listItems)); |
|
| 124 | 124 | |
| 125 | - foreach( $listItems as $listItem ) |
|
| 125 | + foreach ($listItems as $listItem) |
|
| 126 | 126 | { |
| 127 | - $this->assertEquals( $data[$pos++], $listItem->getRefItem()->getCurrencyId() ); |
|
| 128 | - $this->assertEquals( $data[$pos++], $listItem->getRefItem()->getValue() ); |
|
| 127 | + $this->assertEquals($data[$pos++], $listItem->getRefItem()->getCurrencyId()); |
|
| 128 | + $this->assertEquals($data[$pos++], $listItem->getRefItem()->getValue()); |
|
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | |
@@ -147,20 +147,20 @@ discard block |
||
| 147 | 147 | 1 => '2.00', |
| 148 | 148 | ); |
| 149 | 149 | |
| 150 | - $product = $this->create( 'job_csv_test' ); |
|
| 150 | + $product = $this->create('job_csv_test'); |
|
| 151 | 151 | |
| 152 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint ); |
|
| 153 | - $object->process( $product, $data ); |
|
| 154 | - $object->process( $product, $dataUpdate ); |
|
| 152 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint); |
|
| 153 | + $object->process($product, $data); |
|
| 154 | + $object->process($product, $dataUpdate); |
|
| 155 | 155 | |
| 156 | 156 | |
| 157 | 157 | $listItems = $product->getListItems(); |
| 158 | - $listItem = reset( $listItems ); |
|
| 158 | + $listItem = reset($listItems); |
|
| 159 | 159 | |
| 160 | - $this->assertEquals( 1, count( $listItems ) ); |
|
| 161 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem ); |
|
| 160 | + $this->assertEquals(1, count($listItems)); |
|
| 161 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem); |
|
| 162 | 162 | |
| 163 | - $this->assertEquals( '2.00', $listItem->getRefItem()->getValue() ); |
|
| 163 | + $this->assertEquals('2.00', $listItem->getRefItem()->getValue()); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | |
@@ -176,18 +176,18 @@ discard block |
||
| 176 | 176 | 1 => '1.00', |
| 177 | 177 | ); |
| 178 | 178 | |
| 179 | - $product = $this->create( 'job_csv_test' ); |
|
| 179 | + $product = $this->create('job_csv_test'); |
|
| 180 | 180 | |
| 181 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint ); |
|
| 182 | - $object->process( $product, $data ); |
|
| 181 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint); |
|
| 182 | + $object->process($product, $data); |
|
| 183 | 183 | |
| 184 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, [], $this->endpoint ); |
|
| 185 | - $object->process( $product, [] ); |
|
| 184 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, [], $this->endpoint); |
|
| 185 | + $object->process($product, []); |
|
| 186 | 186 | |
| 187 | 187 | |
| 188 | 188 | $listItems = $product->getListItems(); |
| 189 | 189 | |
| 190 | - $this->assertEquals( 0, count( $listItems ) ); |
|
| 190 | + $this->assertEquals(0, count($listItems)); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | |
@@ -207,15 +207,15 @@ discard block |
||
| 207 | 207 | 3 => '', |
| 208 | 208 | ); |
| 209 | 209 | |
| 210 | - $product = $this->create( 'job_csv_test' ); |
|
| 210 | + $product = $this->create('job_csv_test'); |
|
| 211 | 211 | |
| 212 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint ); |
|
| 213 | - $object->process( $product, $data ); |
|
| 212 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint); |
|
| 213 | + $object->process($product, $data); |
|
| 214 | 214 | |
| 215 | 215 | |
| 216 | 216 | $listItems = $product->getListItems(); |
| 217 | 217 | |
| 218 | - $this->assertEquals( 1, count( $listItems ) ); |
|
| 218 | + $this->assertEquals(1, count($listItems)); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | |
@@ -239,31 +239,31 @@ discard block |
||
| 239 | 239 | 5 => 'default', |
| 240 | 240 | ); |
| 241 | 241 | |
| 242 | - $this->context->getConfig()->set( 'controller/common/product/import/csv/processor/price/listtypes', array( 'default' ) ); |
|
| 242 | + $this->context->getConfig()->set('controller/common/product/import/csv/processor/price/listtypes', array('default')); |
|
| 243 | 243 | |
| 244 | - $product = $this->create( 'job_csv_test' ); |
|
| 244 | + $product = $this->create('job_csv_test'); |
|
| 245 | 245 | |
| 246 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint ); |
|
| 247 | - $object->process( $product, $data ); |
|
| 246 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint); |
|
| 247 | + $object->process($product, $data); |
|
| 248 | 248 | |
| 249 | 249 | |
| 250 | 250 | $listItems = $product->getListItems(); |
| 251 | - $listItem = reset( $listItems ); |
|
| 251 | + $listItem = reset($listItems); |
|
| 252 | 252 | |
| 253 | - $this->assertEquals( 1, count( $listItems ) ); |
|
| 254 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem ); |
|
| 253 | + $this->assertEquals(1, count($listItems)); |
|
| 254 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem); |
|
| 255 | 255 | |
| 256 | - $this->assertEquals( 'default', $listItem->getType() ); |
|
| 257 | - $this->assertEquals( '2.00', $listItem->getRefItem()->getValue() ); |
|
| 256 | + $this->assertEquals('default', $listItem->getType()); |
|
| 257 | + $this->assertEquals('2.00', $listItem->getRefItem()->getValue()); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | |
| 261 | 261 | /** |
| 262 | 262 | * @param string $code |
| 263 | 263 | */ |
| 264 | - protected function create( $code ) |
|
| 264 | + protected function create($code) |
|
| 265 | 265 | { |
| 266 | - $manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context ); |
|
| 267 | - return $manager->createItem()->setCode( $code ); |
|
| 266 | + $manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context); |
|
| 267 | + return $manager->createItem()->setCode($code); |
|
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | \ No newline at end of file |
@@ -17,16 +17,16 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | protected function setUp() |
| 19 | 19 | { |
| 20 | - \Aimeos\MShop\Factory::setCache( true ); |
|
| 20 | + \Aimeos\MShop\Factory::setCache(true); |
|
| 21 | 21 | |
| 22 | 22 | $this->context = \TestHelperCntl::getContext(); |
| 23 | - $this->endpoint = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done( $this->context, [] ); |
|
| 23 | + $this->endpoint = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done($this->context, []); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | protected function tearDown() |
| 28 | 28 | { |
| 29 | - \Aimeos\MShop\Factory::setCache( false ); |
|
| 29 | + \Aimeos\MShop\Factory::setCache(false); |
|
| 30 | 30 | \Aimeos\MShop\Factory::clear(); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -49,30 +49,30 @@ discard block |
||
| 49 | 49 | 4 => 1, |
| 50 | 50 | ); |
| 51 | 51 | |
| 52 | - $product = $this->create( 'job_csv_test' ); |
|
| 52 | + $product = $this->create('job_csv_test'); |
|
| 53 | 53 | |
| 54 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard( $this->context, $mapping, $this->endpoint ); |
|
| 55 | - $object->process( $product, $data ); |
|
| 54 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard($this->context, $mapping, $this->endpoint); |
|
| 55 | + $object->process($product, $data); |
|
| 56 | 56 | |
| 57 | 57 | |
| 58 | 58 | $listItems = $product->getListItems(); |
| 59 | - $listItem = reset( $listItems ); |
|
| 59 | + $listItem = reset($listItems); |
|
| 60 | 60 | |
| 61 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem ); |
|
| 62 | - $this->assertEquals( 1, count( $listItems ) ); |
|
| 61 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem); |
|
| 62 | + $this->assertEquals(1, count($listItems)); |
|
| 63 | 63 | |
| 64 | - $this->assertEquals( 1, $listItem->getStatus() ); |
|
| 65 | - $this->assertEquals( 0, $listItem->getPosition() ); |
|
| 66 | - $this->assertEquals( 'default', $listItem->getType() ); |
|
| 64 | + $this->assertEquals(1, $listItem->getStatus()); |
|
| 65 | + $this->assertEquals(0, $listItem->getPosition()); |
|
| 66 | + $this->assertEquals('default', $listItem->getType()); |
|
| 67 | 67 | |
| 68 | 68 | $refItem = $listItem->getRefItem(); |
| 69 | 69 | |
| 70 | - $this->assertEquals( 1, $refItem->getStatus() ); |
|
| 71 | - $this->assertEquals( 'name', $refItem->getType() ); |
|
| 72 | - $this->assertEquals( 'test text', $refItem->getLabel() ); |
|
| 73 | - $this->assertEquals( 'Job CSV test', $refItem->getContent() ); |
|
| 74 | - $this->assertEquals( 'de', $refItem->getLanguageId() ); |
|
| 75 | - $this->assertEquals( 1, $refItem->getStatus() ); |
|
| 70 | + $this->assertEquals(1, $refItem->getStatus()); |
|
| 71 | + $this->assertEquals('name', $refItem->getType()); |
|
| 72 | + $this->assertEquals('test text', $refItem->getLabel()); |
|
| 73 | + $this->assertEquals('Job CSV test', $refItem->getContent()); |
|
| 74 | + $this->assertEquals('de', $refItem->getLanguageId()); |
|
| 75 | + $this->assertEquals(1, $refItem->getStatus()); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | |
@@ -100,27 +100,27 @@ discard block |
||
| 100 | 100 | 7 => 'Long: Job CSV test 2', |
| 101 | 101 | ); |
| 102 | 102 | |
| 103 | - $product = $this->create( 'job_csv_test' ); |
|
| 103 | + $product = $this->create('job_csv_test'); |
|
| 104 | 104 | |
| 105 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard( $this->context, $mapping, $this->endpoint ); |
|
| 106 | - $object->process( $product, $data ); |
|
| 105 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard($this->context, $mapping, $this->endpoint); |
|
| 106 | + $object->process($product, $data); |
|
| 107 | 107 | |
| 108 | 108 | |
| 109 | 109 | $pos = 0; |
| 110 | 110 | $listItems = $product->getListItems(); |
| 111 | 111 | $expected = array( |
| 112 | - 0 => array( 'name', 'Job CSV test' ), |
|
| 113 | - 1 => array( 'short', 'Short: Job CSV test' ), |
|
| 114 | - 2 => array( 'long', 'Long: Job CSV test' ), |
|
| 115 | - 3 => array( 'long', 'Long: Job CSV test 2' ), |
|
| 112 | + 0 => array('name', 'Job CSV test'), |
|
| 113 | + 1 => array('short', 'Short: Job CSV test'), |
|
| 114 | + 2 => array('long', 'Long: Job CSV test'), |
|
| 115 | + 3 => array('long', 'Long: Job CSV test 2'), |
|
| 116 | 116 | ); |
| 117 | 117 | |
| 118 | - $this->assertEquals( 4, count( $listItems ) ); |
|
| 118 | + $this->assertEquals(4, count($listItems)); |
|
| 119 | 119 | |
| 120 | - foreach( $listItems as $listItem ) |
|
| 120 | + foreach ($listItems as $listItem) |
|
| 121 | 121 | { |
| 122 | - $this->assertEquals( $expected[$pos][0], $listItem->getRefItem()->getType() ); |
|
| 123 | - $this->assertEquals( $expected[$pos][1], $listItem->getRefItem()->getContent() ); |
|
| 122 | + $this->assertEquals($expected[$pos][0], $listItem->getRefItem()->getType()); |
|
| 123 | + $this->assertEquals($expected[$pos][1], $listItem->getRefItem()->getContent()); |
|
| 124 | 124 | $pos++; |
| 125 | 125 | } |
| 126 | 126 | } |
@@ -143,21 +143,21 @@ discard block |
||
| 143 | 143 | 1 => 'Short: Job CSV test', |
| 144 | 144 | ); |
| 145 | 145 | |
| 146 | - $product = $this->create( 'job_csv_test' ); |
|
| 146 | + $product = $this->create('job_csv_test'); |
|
| 147 | 147 | |
| 148 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard( $this->context, $mapping, $this->endpoint ); |
|
| 149 | - $object->process( $product, $data ); |
|
| 150 | - $object->process( $product, $dataUpdate ); |
|
| 148 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard($this->context, $mapping, $this->endpoint); |
|
| 149 | + $object->process($product, $data); |
|
| 150 | + $object->process($product, $dataUpdate); |
|
| 151 | 151 | |
| 152 | 152 | |
| 153 | 153 | $listItems = $product->getListItems(); |
| 154 | - $listItem = reset( $listItems ); |
|
| 154 | + $listItem = reset($listItems); |
|
| 155 | 155 | |
| 156 | - $this->assertEquals( 1, count( $listItems ) ); |
|
| 157 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem ); |
|
| 156 | + $this->assertEquals(1, count($listItems)); |
|
| 157 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem); |
|
| 158 | 158 | |
| 159 | - $this->assertEquals( 'short', $listItem->getRefItem()->getType() ); |
|
| 160 | - $this->assertEquals( 'Short: Job CSV test', $listItem->getRefItem()->getContent() ); |
|
| 159 | + $this->assertEquals('short', $listItem->getRefItem()->getType()); |
|
| 160 | + $this->assertEquals('Short: Job CSV test', $listItem->getRefItem()->getContent()); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | |
@@ -173,18 +173,18 @@ discard block |
||
| 173 | 173 | 1 => 'Job CSV test', |
| 174 | 174 | ); |
| 175 | 175 | |
| 176 | - $product = $this->create( 'job_csv_test' ); |
|
| 176 | + $product = $this->create('job_csv_test'); |
|
| 177 | 177 | |
| 178 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard( $this->context, $mapping, $this->endpoint ); |
|
| 179 | - $object->process( $product, $data ); |
|
| 178 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard($this->context, $mapping, $this->endpoint); |
|
| 179 | + $object->process($product, $data); |
|
| 180 | 180 | |
| 181 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard( $this->context, [], $this->endpoint ); |
|
| 182 | - $object->process( $product, [] ); |
|
| 181 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard($this->context, [], $this->endpoint); |
|
| 182 | + $object->process($product, []); |
|
| 183 | 183 | |
| 184 | 184 | |
| 185 | 185 | $listItems = $product->getListItems(); |
| 186 | 186 | |
| 187 | - $this->assertEquals( 0, count( $listItems ) ); |
|
| 187 | + $this->assertEquals(0, count($listItems)); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | |
@@ -204,15 +204,15 @@ discard block |
||
| 204 | 204 | 3 => '', |
| 205 | 205 | ); |
| 206 | 206 | |
| 207 | - $product = $this->create( 'job_csv_test' ); |
|
| 207 | + $product = $this->create('job_csv_test'); |
|
| 208 | 208 | |
| 209 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard( $this->context, $mapping, $this->endpoint ); |
|
| 210 | - $object->process( $product, $data ); |
|
| 209 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard($this->context, $mapping, $this->endpoint); |
|
| 210 | + $object->process($product, $data); |
|
| 211 | 211 | |
| 212 | 212 | |
| 213 | 213 | $listItems = $product->getListItems(); |
| 214 | 214 | |
| 215 | - $this->assertEquals( 1, count( $listItems ) ); |
|
| 215 | + $this->assertEquals(1, count($listItems)); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | |
@@ -236,32 +236,32 @@ discard block |
||
| 236 | 236 | 5 => 'default', |
| 237 | 237 | ); |
| 238 | 238 | |
| 239 | - $this->context->getConfig()->set( 'controller/common/product/import/csv/processor/text/listtypes', array( 'default' ) ); |
|
| 239 | + $this->context->getConfig()->set('controller/common/product/import/csv/processor/text/listtypes', array('default')); |
|
| 240 | 240 | |
| 241 | - $product = $this->create( 'job_csv_test' ); |
|
| 241 | + $product = $this->create('job_csv_test'); |
|
| 242 | 242 | |
| 243 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard( $this->context, $mapping, $this->endpoint ); |
|
| 244 | - $object->process( $product, $data ); |
|
| 243 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard($this->context, $mapping, $this->endpoint); |
|
| 244 | + $object->process($product, $data); |
|
| 245 | 245 | |
| 246 | 246 | |
| 247 | 247 | $listItems = $product->getListItems(); |
| 248 | - $listItem = reset( $listItems ); |
|
| 248 | + $listItem = reset($listItems); |
|
| 249 | 249 | |
| 250 | - $this->assertEquals( 1, count( $listItems ) ); |
|
| 251 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem ); |
|
| 250 | + $this->assertEquals(1, count($listItems)); |
|
| 251 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem); |
|
| 252 | 252 | |
| 253 | - $this->assertEquals( 'default', $listItem->getType() ); |
|
| 254 | - $this->assertEquals( 'short', $listItem->getRefItem()->getType() ); |
|
| 255 | - $this->assertEquals( 'test short', $listItem->getRefItem()->getContent() ); |
|
| 253 | + $this->assertEquals('default', $listItem->getType()); |
|
| 254 | + $this->assertEquals('short', $listItem->getRefItem()->getType()); |
|
| 255 | + $this->assertEquals('test short', $listItem->getRefItem()->getContent()); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | |
| 259 | 259 | /** |
| 260 | 260 | * @param string $code |
| 261 | 261 | */ |
| 262 | - protected function create( $code ) |
|
| 262 | + protected function create($code) |
|
| 263 | 263 | { |
| 264 | - $manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context ); |
|
| 265 | - return $manager->createItem()->setCode( $code ); |
|
| 264 | + $manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context); |
|
| 265 | + return $manager->createItem()->setCode($code); |
|
| 266 | 266 | } |
| 267 | 267 | } |
| 268 | 268 | \ No newline at end of file |
@@ -17,16 +17,16 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | protected function setUp() |
| 19 | 19 | { |
| 20 | - \Aimeos\MShop\Factory::setCache( true ); |
|
| 20 | + \Aimeos\MShop\Factory::setCache(true); |
|
| 21 | 21 | |
| 22 | 22 | $this->context = \TestHelperCntl::getContext(); |
| 23 | - $this->endpoint = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done( $this->context, [] ); |
|
| 23 | + $this->endpoint = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done($this->context, []); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | protected function tearDown() |
| 28 | 28 | { |
| 29 | - \Aimeos\MShop\Factory::setCache( false ); |
|
| 29 | + \Aimeos\MShop\Factory::setCache(false); |
|
| 30 | 30 | \Aimeos\MShop\Factory::clear(); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -57,29 +57,29 @@ discard block |
||
| 57 | 57 | 8 => 'variant', |
| 58 | 58 | ); |
| 59 | 59 | |
| 60 | - $product = $this->create( 'job_csv_test' ); |
|
| 60 | + $product = $this->create('job_csv_test'); |
|
| 61 | 61 | |
| 62 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Attribute\Standard( $this->context, $mapping, $this->endpoint ); |
|
| 63 | - $object->process( $product, $data ); |
|
| 62 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Attribute\Standard($this->context, $mapping, $this->endpoint); |
|
| 63 | + $object->process($product, $data); |
|
| 64 | 64 | |
| 65 | 65 | |
| 66 | 66 | $pos = 0; |
| 67 | 67 | $listItems = $product->getListItems(); |
| 68 | 68 | $expected = array( |
| 69 | - array( 'variant', 'length', '30' ), |
|
| 70 | - array( 'variant', 'width', '29' ), |
|
| 71 | - array( 'variant', 'color', 'white' ), |
|
| 69 | + array('variant', 'length', '30'), |
|
| 70 | + array('variant', 'width', '29'), |
|
| 71 | + array('variant', 'color', 'white'), |
|
| 72 | 72 | ); |
| 73 | 73 | |
| 74 | - $this->assertEquals( 3, count( $listItems ) ); |
|
| 74 | + $this->assertEquals(3, count($listItems)); |
|
| 75 | 75 | |
| 76 | - foreach( $listItems as $listItem ) |
|
| 76 | + foreach ($listItems as $listItem) |
|
| 77 | 77 | { |
| 78 | - $this->assertEquals( 1, $listItem->getStatus() ); |
|
| 79 | - $this->assertEquals( 'attribute', $listItem->getDomain() ); |
|
| 80 | - $this->assertEquals( $expected[$pos][0], $listItem->getType() ); |
|
| 81 | - $this->assertEquals( $expected[$pos][1], $listItem->getRefItem()->getType() ); |
|
| 82 | - $this->assertEquals( $expected[$pos][2], $listItem->getRefItem()->getCode() ); |
|
| 78 | + $this->assertEquals(1, $listItem->getStatus()); |
|
| 79 | + $this->assertEquals('attribute', $listItem->getDomain()); |
|
| 80 | + $this->assertEquals($expected[$pos][0], $listItem->getType()); |
|
| 81 | + $this->assertEquals($expected[$pos][1], $listItem->getRefItem()->getType()); |
|
| 82 | + $this->assertEquals($expected[$pos][2], $listItem->getRefItem()->getCode()); |
|
| 83 | 83 | $pos++; |
| 84 | 84 | } |
| 85 | 85 | } |
@@ -99,25 +99,25 @@ discard block |
||
| 99 | 99 | 2 => 'variant', |
| 100 | 100 | ); |
| 101 | 101 | |
| 102 | - $product = $this->create( 'job_csv_test' ); |
|
| 102 | + $product = $this->create('job_csv_test'); |
|
| 103 | 103 | |
| 104 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Catalog\Standard( $this->context, $mapping, $this->endpoint ); |
|
| 105 | - $object->process( $product, $data ); |
|
| 104 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Catalog\Standard($this->context, $mapping, $this->endpoint); |
|
| 105 | + $object->process($product, $data); |
|
| 106 | 106 | |
| 107 | 107 | |
| 108 | 108 | $pos = 0; |
| 109 | - $codes = array( 'white', 'black', 'aimeos' ); |
|
| 109 | + $codes = array('white', 'black', 'aimeos'); |
|
| 110 | 110 | |
| 111 | - foreach( $product->getListItems() as $listItems ) |
|
| 111 | + foreach ($product->getListItems() as $listItems) |
|
| 112 | 112 | { |
| 113 | - $this->assertEquals( 3, count( $listItems ) ); |
|
| 113 | + $this->assertEquals(3, count($listItems)); |
|
| 114 | 114 | |
| 115 | - foreach( $listItems as $listItem ) |
|
| 115 | + foreach ($listItems as $listItem) |
|
| 116 | 116 | { |
| 117 | - $this->assertEquals( 1, $listItem->getStatus() ); |
|
| 118 | - $this->assertEquals( 'attribute', $listItem->getDomain() ); |
|
| 119 | - $this->assertEquals( 'variant', $listItem->getType() ); |
|
| 120 | - $this->assertEquals( $codes[$pos], $listItem->getRefItem()->getCode() ); |
|
| 117 | + $this->assertEquals(1, $listItem->getStatus()); |
|
| 118 | + $this->assertEquals('attribute', $listItem->getDomain()); |
|
| 119 | + $this->assertEquals('variant', $listItem->getType()); |
|
| 120 | + $this->assertEquals($codes[$pos], $listItem->getRefItem()->getCode()); |
|
| 121 | 121 | $pos++; |
| 122 | 122 | } |
| 123 | 123 | } |
@@ -141,21 +141,21 @@ discard block |
||
| 141 | 141 | 1 => '29', |
| 142 | 142 | ); |
| 143 | 143 | |
| 144 | - $product = $this->create( 'job_csv_test' ); |
|
| 144 | + $product = $this->create('job_csv_test'); |
|
| 145 | 145 | |
| 146 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Attribute\Standard( $this->context, $mapping, $this->endpoint ); |
|
| 147 | - $object->process( $product, $data ); |
|
| 148 | - $object->process( $product, $dataUpdate ); |
|
| 146 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Attribute\Standard($this->context, $mapping, $this->endpoint); |
|
| 147 | + $object->process($product, $data); |
|
| 148 | + $object->process($product, $dataUpdate); |
|
| 149 | 149 | |
| 150 | 150 | |
| 151 | 151 | $listItems = $product->getListItems(); |
| 152 | - $listItem = reset( $listItems ); |
|
| 152 | + $listItem = reset($listItems); |
|
| 153 | 153 | |
| 154 | - $this->assertEquals( 1, count( $listItems ) ); |
|
| 155 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem ); |
|
| 154 | + $this->assertEquals(1, count($listItems)); |
|
| 155 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem); |
|
| 156 | 156 | |
| 157 | - $this->assertEquals( 'width', $listItem->getRefItem()->getType() ); |
|
| 158 | - $this->assertEquals( '29', $listItem->getRefItem()->getCode() ); |
|
| 157 | + $this->assertEquals('width', $listItem->getRefItem()->getType()); |
|
| 158 | + $this->assertEquals('29', $listItem->getRefItem()->getCode()); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | |
@@ -171,18 +171,18 @@ discard block |
||
| 171 | 171 | 1 => '30', |
| 172 | 172 | ); |
| 173 | 173 | |
| 174 | - $product = $this->create( 'job_csv_test' ); |
|
| 174 | + $product = $this->create('job_csv_test'); |
|
| 175 | 175 | |
| 176 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Attribute\Standard( $this->context, $mapping, $this->endpoint ); |
|
| 177 | - $object->process( $product, $data ); |
|
| 176 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Attribute\Standard($this->context, $mapping, $this->endpoint); |
|
| 177 | + $object->process($product, $data); |
|
| 178 | 178 | |
| 179 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Attribute\Standard( $this->context, [], $this->endpoint ); |
|
| 180 | - $object->process( $product, [] ); |
|
| 179 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Attribute\Standard($this->context, [], $this->endpoint); |
|
| 180 | + $object->process($product, []); |
|
| 181 | 181 | |
| 182 | 182 | |
| 183 | 183 | $listItems = $product->getListItems(); |
| 184 | 184 | |
| 185 | - $this->assertEquals( 0, count( $listItems ) ); |
|
| 185 | + $this->assertEquals(0, count($listItems)); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | |
@@ -202,15 +202,15 @@ discard block |
||
| 202 | 202 | 3 => '30', |
| 203 | 203 | ); |
| 204 | 204 | |
| 205 | - $product = $this->create( 'job_csv_test' ); |
|
| 205 | + $product = $this->create('job_csv_test'); |
|
| 206 | 206 | |
| 207 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Attribute\Standard( $this->context, $mapping, $this->endpoint ); |
|
| 208 | - $object->process( $product, $data ); |
|
| 207 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Attribute\Standard($this->context, $mapping, $this->endpoint); |
|
| 208 | + $object->process($product, $data); |
|
| 209 | 209 | |
| 210 | 210 | |
| 211 | 211 | $listItems = $product->getListItems(); |
| 212 | 212 | |
| 213 | - $this->assertEquals( 1, count( $listItems ) ); |
|
| 213 | + $this->assertEquals(1, count($listItems)); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | |
@@ -226,17 +226,17 @@ discard block |
||
| 226 | 226 | 1 => '30', |
| 227 | 227 | ); |
| 228 | 228 | |
| 229 | - $product = $this->create( 'job_csv_test' ); |
|
| 229 | + $product = $this->create('job_csv_test'); |
|
| 230 | 230 | |
| 231 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Attribute\Standard( $this->context, $mapping, $this->endpoint ); |
|
| 231 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Attribute\Standard($this->context, $mapping, $this->endpoint); |
|
| 232 | 232 | |
| 233 | 233 | try { |
| 234 | - $object->process( $product, $data ); |
|
| 235 | - } catch( \Exception $e ) { |
|
| 234 | + $object->process($product, $data); |
|
| 235 | + } catch (\Exception $e) { |
|
| 236 | 236 | return; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - $this->markTestFail( 'No exception thrown' ); |
|
| 239 | + $this->markTestFail('No exception thrown'); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | |
@@ -260,32 +260,32 @@ discard block |
||
| 260 | 260 | 5 => 'default', |
| 261 | 261 | ); |
| 262 | 262 | |
| 263 | - $this->context->getConfig()->set( 'controller/common/product/import/csv/processor/attribute/listtypes', array( 'default' ) ); |
|
| 263 | + $this->context->getConfig()->set('controller/common/product/import/csv/processor/attribute/listtypes', array('default')); |
|
| 264 | 264 | |
| 265 | - $product = $this->create( 'job_csv_test' ); |
|
| 265 | + $product = $this->create('job_csv_test'); |
|
| 266 | 266 | |
| 267 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Attribute\Standard( $this->context, $mapping, $this->endpoint ); |
|
| 268 | - $object->process( $product, $data ); |
|
| 267 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Attribute\Standard($this->context, $mapping, $this->endpoint); |
|
| 268 | + $object->process($product, $data); |
|
| 269 | 269 | |
| 270 | 270 | |
| 271 | 271 | $listItems = $product->getListItems(); |
| 272 | - $listItem = reset( $listItems ); |
|
| 272 | + $listItem = reset($listItems); |
|
| 273 | 273 | |
| 274 | - $this->assertEquals( 1, count( $listItems ) ); |
|
| 275 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem ); |
|
| 274 | + $this->assertEquals(1, count($listItems)); |
|
| 275 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem); |
|
| 276 | 276 | |
| 277 | - $this->assertEquals( 'default', $listItem->getType() ); |
|
| 278 | - $this->assertEquals( 'width', $listItem->getRefItem()->getType() ); |
|
| 279 | - $this->assertEquals( '30', $listItem->getRefItem()->getCode() ); |
|
| 277 | + $this->assertEquals('default', $listItem->getType()); |
|
| 278 | + $this->assertEquals('width', $listItem->getRefItem()->getType()); |
|
| 279 | + $this->assertEquals('30', $listItem->getRefItem()->getCode()); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | |
| 283 | 283 | /** |
| 284 | 284 | * @param string $code |
| 285 | 285 | */ |
| 286 | - protected function create( $code ) |
|
| 286 | + protected function create($code) |
|
| 287 | 287 | { |
| 288 | - $manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context ); |
|
| 289 | - return $manager->createItem()->setCode( $code ); |
|
| 288 | + $manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context); |
|
| 289 | + return $manager->createItem()->setCode($code); |
|
| 290 | 290 | } |
| 291 | 291 | } |
| 292 | 292 | \ No newline at end of file |
@@ -40,44 +40,44 @@ |
||
| 40 | 40 | * @param array $data List of CSV fields with position as key and data as value |
| 41 | 41 | * @return array List of data which hasn't been imported |
| 42 | 42 | */ |
| 43 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
| 43 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
| 44 | 44 | { |
| 45 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/property' ); |
|
| 45 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/property'); |
|
| 46 | 46 | |
| 47 | 47 | $propMap = []; |
| 48 | - $items = $product->getPropertyItems( null, false ); |
|
| 49 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
| 48 | + $items = $product->getPropertyItems(null, false); |
|
| 49 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
| 50 | 50 | |
| 51 | - foreach( $items as $item ) { |
|
| 52 | - $propMap[ $item->getValue() ][ $item->getType() ] = $item; |
|
| 51 | + foreach ($items as $item) { |
|
| 52 | + $propMap[$item->getValue()][$item->getType()] = $item; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - foreach( $map as $list ) |
|
| 55 | + foreach ($map as $list) |
|
| 56 | 56 | { |
| 57 | - $typecode = trim( $list['product.property.type'] ); |
|
| 58 | - $value = trim( $list['product.property.value'] ); |
|
| 57 | + $typecode = trim($list['product.property.type']); |
|
| 58 | + $value = trim($list['product.property.value']); |
|
| 59 | 59 | |
| 60 | - if( $typecode == '' || $value == '' ) { |
|
| 60 | + if ($typecode == '' || $value == '') { |
|
| 61 | 61 | continue; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - if( isset( $propMap[$value][$typecode] ) ) |
|
| 64 | + if (isset($propMap[$value][$typecode])) |
|
| 65 | 65 | { |
| 66 | 66 | $item = $propMap[$value][$typecode]; |
| 67 | - unset( $items[ $item->getId() ] ); |
|
| 67 | + unset($items[$item->getId()]); |
|
| 68 | 68 | } |
| 69 | 69 | else |
| 70 | 70 | { |
| 71 | - $item = $manager->createItem( $typecode, 'product' ); |
|
| 71 | + $item = $manager->createItem($typecode, 'product'); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - $item->fromArray( $list ); |
|
| 74 | + $item->fromArray($list); |
|
| 75 | 75 | |
| 76 | - $product->addPropertyItem( $item ); |
|
| 76 | + $product->addPropertyItem($item); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - $product->deletePropertyItems( $items ); |
|
| 79 | + $product->deletePropertyItems($items); |
|
| 80 | 80 | |
| 81 | - return $this->getObject()->process( $product, $data ); |
|
| 81 | + return $this->getObject()->process($product, $data); |
|
| 82 | 82 | } |
| 83 | 83 | } |
@@ -65,8 +65,7 @@ |
||
| 65 | 65 | { |
| 66 | 66 | $item = $propMap[$value][$typecode]; |
| 67 | 67 | unset( $items[ $item->getId() ] ); |
| 68 | - } |
|
| 69 | - else |
|
| 68 | + } else |
|
| 70 | 69 | { |
| 71 | 70 | $item = $manager->createItem( $typecode, 'product' ); |
| 72 | 71 | } |
@@ -42,10 +42,10 @@ 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 | 50 | /** controller/common/product/import/csv/processor/media/listtypes |
| 51 | 51 | * Names of the product list types for media that are updated or removed |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * @see controller/common/product/import/csv/processor/price/listtypes |
| 67 | 67 | * @see controller/common/product/import/csv/processor/text/listtypes |
| 68 | 68 | */ |
| 69 | - $this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/media/listtypes' ); |
|
| 69 | + $this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/media/listtypes'); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | |
@@ -77,62 +77,62 @@ discard block |
||
| 77 | 77 | * @param array $data List of CSV fields with position as key and data as value |
| 78 | 78 | * @return array List of data which hasn't been imported |
| 79 | 79 | */ |
| 80 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
| 80 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
| 81 | 81 | { |
| 82 | 82 | $context = $this->getContext(); |
| 83 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'media' ); |
|
| 84 | - $listManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' ); |
|
| 85 | - $separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" ); |
|
| 83 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'media'); |
|
| 84 | + $listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); |
|
| 85 | + $separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n"); |
|
| 86 | 86 | |
| 87 | 87 | $listMap = []; |
| 88 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
| 89 | - $listItems = $product->getListItems( 'media', $this->listTypes ); |
|
| 88 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
| 89 | + $listItems = $product->getListItems('media', $this->listTypes); |
|
| 90 | 90 | |
| 91 | - foreach( $listItems as $listItem ) |
|
| 91 | + foreach ($listItems as $listItem) |
|
| 92 | 92 | { |
| 93 | - if( ( $refItem = $listItem->getRefItem() ) !== null ) { |
|
| 94 | - $listMap[ $refItem->getUrl() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem; |
|
| 93 | + if (($refItem = $listItem->getRefItem()) !== null) { |
|
| 94 | + $listMap[$refItem->getUrl()][$refItem->getType()][$listItem->getType()] = $listItem; |
|
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - foreach( $map as $pos => $list ) |
|
| 98 | + foreach ($map as $pos => $list) |
|
| 99 | 99 | { |
| 100 | - if( $this->checkEntry( $list ) === false ) { |
|
| 100 | + if ($this->checkEntry($list) === false) { |
|
| 101 | 101 | continue; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - $urls = explode( $separator, trim( $list['media.url'] ) ); |
|
| 105 | - $type = trim( $this->getValue( $list, 'media.type', 'default' ) ); |
|
| 106 | - $typecode = trim( $this->getValue( $list, 'product.lists.type', 'default' ) ); |
|
| 104 | + $urls = explode($separator, trim($list['media.url'])); |
|
| 105 | + $type = trim($this->getValue($list, 'media.type', 'default')); |
|
| 106 | + $typecode = trim($this->getValue($list, 'product.lists.type', 'default')); |
|
| 107 | 107 | |
| 108 | - foreach( $urls as $url ) |
|
| 108 | + foreach ($urls as $url) |
|
| 109 | 109 | { |
| 110 | - $url = trim( $url ); |
|
| 110 | + $url = trim($url); |
|
| 111 | 111 | |
| 112 | - if( isset( $listMap[$url][$type][$typecode] ) ) |
|
| 112 | + if (isset($listMap[$url][$type][$typecode])) |
|
| 113 | 113 | { |
| 114 | 114 | $listItem = $listMap[$url][$type][$typecode]; |
| 115 | 115 | $refItem = $listItem->getRefItem(); |
| 116 | - unset( $listItems[ $listItem->getId() ] ); |
|
| 116 | + unset($listItems[$listItem->getId()]); |
|
| 117 | 117 | } |
| 118 | 118 | else |
| 119 | 119 | { |
| 120 | - $listItem = $listManager->createItem( $typecode, 'media' ); |
|
| 121 | - $refItem = $manager->createItem( $type, 'product' ); |
|
| 120 | + $listItem = $listManager->createItem($typecode, 'media'); |
|
| 121 | + $refItem = $manager->createItem($type, 'product'); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | $list['media.url'] = $url; |
| 125 | 125 | |
| 126 | - $refItem->fromArray( $this->addItemDefaults( $list ) ); |
|
| 127 | - $listItem->fromArray( $this->addListItemDefaults( $list, $pos++ ) ); |
|
| 126 | + $refItem->fromArray($this->addItemDefaults($list)); |
|
| 127 | + $listItem->fromArray($this->addListItemDefaults($list, $pos++)); |
|
| 128 | 128 | |
| 129 | - $product->addListItem( 'media', $listItem, $refItem ); |
|
| 129 | + $product->addListItem('media', $listItem, $refItem); |
|
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - $product->deleteListItems( $listItems, true ); |
|
| 133 | + $product->deleteListItems($listItems, true); |
|
| 134 | 134 | |
| 135 | - return $this->getObject()->process( $product, $data ); |
|
| 135 | + return $this->getObject()->process($product, $data); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | |
@@ -142,17 +142,17 @@ discard block |
||
| 142 | 142 | * @param array $list Associative list of domain item keys and their values, e.g. "media.status" => 1 |
| 143 | 143 | * @return array Given associative list enriched by default values if they were not already set |
| 144 | 144 | */ |
| 145 | - protected function addItemDefaults( array $list ) |
|
| 145 | + protected function addItemDefaults(array $list) |
|
| 146 | 146 | { |
| 147 | - if( !isset( $list['media.label'] ) ) { |
|
| 147 | + if (!isset($list['media.label'])) { |
|
| 148 | 148 | $list['media.label'] = $list['media.url']; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - if( !isset( $list['media.preview'] ) ) { |
|
| 151 | + if (!isset($list['media.preview'])) { |
|
| 152 | 152 | $list['media.preview'] = $list['media.url']; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - if( !isset( $list['media.status'] ) ) { |
|
| 155 | + if (!isset($list['media.status'])) { |
|
| 156 | 156 | $list['media.status'] = 1; |
| 157 | 157 | } |
| 158 | 158 | |
@@ -166,10 +166,10 @@ discard block |
||
| 166 | 166 | * @param array $list Associative list of key/value pairs from the mapping |
| 167 | 167 | * @return boolean True if valid, false if not |
| 168 | 168 | */ |
| 169 | - protected function checkEntry( array $list ) |
|
| 169 | + protected function checkEntry(array $list) |
|
| 170 | 170 | { |
| 171 | - if( !isset( $list['media.url'] ) || trim( $list['media.url'] ) === '' || isset( $list['product.lists.type'] ) |
|
| 172 | - && $this->listTypes !== null && !in_array( trim( $list['product.lists.type'] ), (array) $this->listTypes ) |
|
| 171 | + if (!isset($list['media.url']) || trim($list['media.url']) === '' || isset($list['product.lists.type']) |
|
| 172 | + && $this->listTypes !== null && !in_array(trim($list['product.lists.type']), (array) $this->listTypes) |
|
| 173 | 173 | ) { |
| 174 | 174 | return false; |
| 175 | 175 | } |
@@ -114,8 +114,7 @@ |
||
| 114 | 114 | $listItem = $listMap[$url][$type][$typecode]; |
| 115 | 115 | $refItem = $listItem->getRefItem(); |
| 116 | 116 | unset( $listItems[ $listItem->getId() ] ); |
| 117 | - } |
|
| 118 | - else |
|
| 117 | + } else |
|
| 119 | 118 | { |
| 120 | 119 | $listItem = $listManager->createItem( $typecode, 'media' ); |
| 121 | 120 | $refItem = $manager->createItem( $type, 'product' ); |
@@ -43,10 +43,10 @@ discard block |
||
| 43 | 43 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
| 44 | 44 | * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor |
| 45 | 45 | */ |
| 46 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 47 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null ) |
|
| 46 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 47 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null) |
|
| 48 | 48 | { |
| 49 | - parent::__construct( $context, $mapping, $object ); |
|
| 49 | + parent::__construct($context, $mapping, $object); |
|
| 50 | 50 | |
| 51 | 51 | /** controller/common/product/import/csv/processor/product/listtypes |
| 52 | 52 | * Names of the product list types that are updated or removed |
@@ -73,11 +73,11 @@ discard block |
||
| 73 | 73 | * @see controller/common/product/import/csv/processor/price/listtypes |
| 74 | 74 | * @see controller/common/product/import/csv/processor/text/listtypes |
| 75 | 75 | */ |
| 76 | - $default = array( 'default', 'suggestion' ); |
|
| 76 | + $default = array('default', 'suggestion'); |
|
| 77 | 77 | $key = 'controller/common/product/import/csv/processor/product/listtypes'; |
| 78 | - $this->listTypes = $context->getConfig()->get( $key, $default ); |
|
| 78 | + $this->listTypes = $context->getConfig()->get($key, $default); |
|
| 79 | 79 | |
| 80 | - $this->cache = $this->getCache( 'product' ); |
|
| 80 | + $this->cache = $this->getCache('product'); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | |
@@ -88,49 +88,49 @@ discard block |
||
| 88 | 88 | * @param array $data List of CSV fields with position as key and data as value |
| 89 | 89 | * @return array List of data which hasn't been imported |
| 90 | 90 | */ |
| 91 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
| 91 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
| 92 | 92 | { |
| 93 | 93 | $context = $this->getContext(); |
| 94 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' ); |
|
| 95 | - $separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" ); |
|
| 94 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); |
|
| 95 | + $separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n"); |
|
| 96 | 96 | |
| 97 | - $listItems = $product->getListItems( 'product', null, null, false ); |
|
| 98 | - $this->cache->set( $product ); |
|
| 97 | + $listItems = $product->getListItems('product', null, null, false); |
|
| 98 | + $this->cache->set($product); |
|
| 99 | 99 | |
| 100 | - foreach( $this->getMappedChunk( $data, $this->getMapping() ) as $list ) |
|
| 100 | + foreach ($this->getMappedChunk($data, $this->getMapping()) as $list) |
|
| 101 | 101 | { |
| 102 | - if( $this->checkEntry( $list ) === false ) { |
|
| 102 | + if ($this->checkEntry($list) === false) { |
|
| 103 | 103 | continue; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - $type = trim( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' ); |
|
| 106 | + $type = trim(isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default'); |
|
| 107 | 107 | |
| 108 | - foreach( explode( $separator, trim( $list['product.code'] ) ) as $code ) |
|
| 108 | + foreach (explode($separator, trim($list['product.code'])) as $code) |
|
| 109 | 109 | { |
| 110 | - $code = trim( $code ); |
|
| 110 | + $code = trim($code); |
|
| 111 | 111 | |
| 112 | - if( ( $prodid = $this->cache->get( $code ) ) === null ) |
|
| 112 | + if (($prodid = $this->cache->get($code)) === null) |
|
| 113 | 113 | { |
| 114 | 114 | $msg = 'No product for code "%1$s" available when importing product with code "%2$s"'; |
| 115 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( $msg, $code, $product->getCode() ) ); |
|
| 115 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf($msg, $code, $product->getCode())); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - if( ( $listItem = $product->getListItem( 'product', $type, $prodid ) ) === null ) { |
|
| 119 | - $listItem = $manager->createItem( $type, 'product' ); |
|
| 118 | + if (($listItem = $product->getListItem('product', $type, $prodid)) === null) { |
|
| 119 | + $listItem = $manager->createItem($type, 'product'); |
|
| 120 | 120 | } else { |
| 121 | - unset( $listItems[$listItem->getId()] ); |
|
| 121 | + unset($listItems[$listItem->getId()]); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - $listItem->fromArray( $list ); |
|
| 125 | - $listItem->setRefId( $prodid ); |
|
| 124 | + $listItem->fromArray($list); |
|
| 125 | + $listItem->setRefId($prodid); |
|
| 126 | 126 | |
| 127 | - $product->addListItem( 'product', $listItem ); |
|
| 127 | + $product->addListItem('product', $listItem); |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - $product->deleteListItems( $listItems ); |
|
| 131 | + $product->deleteListItems($listItems); |
|
| 132 | 132 | |
| 133 | - return $this->getObject()->process( $product, $data ); |
|
| 133 | + return $this->getObject()->process($product, $data); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | |
@@ -140,10 +140,10 @@ discard block |
||
| 140 | 140 | * @param array $list Associative list of key/value pairs from the mapping |
| 141 | 141 | * @return boolean True if valid, false if not |
| 142 | 142 | */ |
| 143 | - protected function checkEntry( array $list ) |
|
| 143 | + protected function checkEntry(array $list) |
|
| 144 | 144 | { |
| 145 | - if( !isset( $list['product.code'] ) || trim( $list['product.code'] ) === '' || isset( $list['product.lists.type'] ) |
|
| 146 | - && $this->listTypes !== null && !in_array( trim( $list['product.lists.type'] ), (array) $this->listTypes ) |
|
| 145 | + if (!isset($list['product.code']) || trim($list['product.code']) === '' || isset($list['product.lists.type']) |
|
| 146 | + && $this->listTypes !== null && !in_array(trim($list['product.lists.type']), (array) $this->listTypes) |
|
| 147 | 147 | ) { |
| 148 | 148 | return false; |
| 149 | 149 | } |
@@ -42,10 +42,10 @@ 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 | 50 | /** controller/common/product/import/csv/processor/price/listtypes |
| 51 | 51 | * Names of the product list types for prices that are updated or removed |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * @see controller/common/product/import/csv/processor/product/listtypes |
| 67 | 67 | * @see controller/common/product/import/csv/processor/text/listtypes |
| 68 | 68 | */ |
| 69 | - $this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/price/listtypes' ); |
|
| 69 | + $this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/price/listtypes'); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | |
@@ -77,54 +77,54 @@ discard block |
||
| 77 | 77 | * @param array $data List of CSV fields with position as key and data as value |
| 78 | 78 | * @return array List of data which hasn't been imported |
| 79 | 79 | */ |
| 80 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
| 80 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
| 81 | 81 | { |
| 82 | - $listManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' ); |
|
| 83 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'price' ); |
|
| 82 | + $listManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists'); |
|
| 83 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'price'); |
|
| 84 | 84 | |
| 85 | 85 | $listMap = []; |
| 86 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
| 87 | - $listItems = $product->getListItems( 'price', $this->listTypes ); |
|
| 86 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
| 87 | + $listItems = $product->getListItems('price', $this->listTypes); |
|
| 88 | 88 | |
| 89 | - foreach( $listItems as $listItem ) |
|
| 89 | + foreach ($listItems as $listItem) |
|
| 90 | 90 | { |
| 91 | - if( ( $refItem = $listItem->getRefItem() ) !== null ) { |
|
| 92 | - $listMap[ $refItem->getValue() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem; |
|
| 91 | + if (($refItem = $listItem->getRefItem()) !== null) { |
|
| 92 | + $listMap[$refItem->getValue()][$refItem->getType()][$listItem->getType()] = $listItem; |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - foreach( $map as $pos => $list ) |
|
| 96 | + foreach ($map as $pos => $list) |
|
| 97 | 97 | { |
| 98 | - if( $this->checkEntry( $list ) === false ) { |
|
| 98 | + if ($this->checkEntry($list) === false) { |
|
| 99 | 99 | continue; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - $value = trim( isset( $list['price.value'] ) ? $list['price.value'] : '0.00' ); |
|
| 103 | - $type = trim( isset( $list['price.type'] ) ? $list['price.type'] : 'default' ); |
|
| 104 | - $typecode = trim( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' ); |
|
| 102 | + $value = trim(isset($list['price.value']) ? $list['price.value'] : '0.00'); |
|
| 103 | + $type = trim(isset($list['price.type']) ? $list['price.type'] : 'default'); |
|
| 104 | + $typecode = trim(isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default'); |
|
| 105 | 105 | |
| 106 | - if( isset( $listMap[$value][$type][$typecode] ) ) |
|
| 106 | + if (isset($listMap[$value][$type][$typecode])) |
|
| 107 | 107 | { |
| 108 | 108 | $listItem = $listMap[$value][$type][$typecode]; |
| 109 | 109 | $refItem = $listItem->getRefItem(); |
| 110 | - unset( $listItems[ $listItem->getId() ] ); |
|
| 110 | + unset($listItems[$listItem->getId()]); |
|
| 111 | 111 | } |
| 112 | 112 | else |
| 113 | 113 | { |
| 114 | - $listItem = $listManager->createItem( $typecode, 'price' ); |
|
| 115 | - $refItem = $manager->createItem( $type, 'product' ); |
|
| 114 | + $listItem = $listManager->createItem($typecode, 'price'); |
|
| 115 | + $refItem = $manager->createItem($type, 'product'); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | |
| 119 | - $refItem->fromArray( $this->addItemDefaults( $list ) ); |
|
| 120 | - $listItem->fromArray( $this->addListItemDefaults( $list, $pos ) ); |
|
| 119 | + $refItem->fromArray($this->addItemDefaults($list)); |
|
| 120 | + $listItem->fromArray($this->addListItemDefaults($list, $pos)); |
|
| 121 | 121 | |
| 122 | - $product->addListItem( 'price', $listItem, $refItem ); |
|
| 122 | + $product->addListItem('price', $listItem, $refItem); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - $product->deleteListItems( $listItems, true ); |
|
| 125 | + $product->deleteListItems($listItems, true); |
|
| 126 | 126 | |
| 127 | - return $this->getObject()->process( $product, $data ); |
|
| 127 | + return $this->getObject()->process($product, $data); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | |
@@ -134,13 +134,13 @@ discard block |
||
| 134 | 134 | * @param array $list Associative list of domain item keys and their values, e.g. "price.status" => 1 |
| 135 | 135 | * @return array Given associative list enriched by default values if they were not already set |
| 136 | 136 | */ |
| 137 | - protected function addItemDefaults( array $list ) |
|
| 137 | + protected function addItemDefaults(array $list) |
|
| 138 | 138 | { |
| 139 | - if( !isset( $list['price.label'] ) ) { |
|
| 139 | + if (!isset($list['price.label'])) { |
|
| 140 | 140 | $list['price.label'] = $list['price.currencyid'] . ' ' . $list['price.value']; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - if( !isset( $list['price.status'] ) ) { |
|
| 143 | + if (!isset($list['price.status'])) { |
|
| 144 | 144 | $list['price.status'] = 1; |
| 145 | 145 | } |
| 146 | 146 | |
@@ -154,10 +154,10 @@ 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( !isset( $list['price.value'] ) || trim( $list['price.value'] ) === '' || isset( $list['product.lists.type'] ) |
|
| 160 | - && $this->listTypes !== null && !in_array( trim( $list['product.lists.type'] ), (array) $this->listTypes ) |
|
| 159 | + if (!isset($list['price.value']) || trim($list['price.value']) === '' || isset($list['product.lists.type']) |
|
| 160 | + && $this->listTypes !== null && !in_array(trim($list['product.lists.type']), (array) $this->listTypes) |
|
| 161 | 161 | ) { |
| 162 | 162 | return false; |
| 163 | 163 | } |
@@ -108,8 +108,7 @@ |
||
| 108 | 108 | $listItem = $listMap[$value][$type][$typecode]; |
| 109 | 109 | $refItem = $listItem->getRefItem(); |
| 110 | 110 | unset( $listItems[ $listItem->getId() ] ); |
| 111 | - } |
|
| 112 | - else |
|
| 111 | + } else |
|
| 113 | 112 | { |
| 114 | 113 | $listItem = $listManager->createItem( $typecode, 'price' ); |
| 115 | 114 | $refItem = $manager->createItem( $type, 'product' ); |
@@ -43,10 +43,10 @@ discard block |
||
| 43 | 43 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
| 44 | 44 | * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor |
| 45 | 45 | */ |
| 46 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 47 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null ) |
|
| 46 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 47 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null) |
|
| 48 | 48 | { |
| 49 | - parent::__construct( $context, $mapping, $object ); |
|
| 49 | + parent::__construct($context, $mapping, $object); |
|
| 50 | 50 | |
| 51 | 51 | /** controller/common/product/import/csv/processor/catalog/listtypes |
| 52 | 52 | * Names of the catalog list types that are updated or removed |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | * @see controller/common/product/import/csv/processor/product/listtypes |
| 68 | 68 | * @see controller/common/product/import/csv/processor/text/listtypes |
| 69 | 69 | */ |
| 70 | - $this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/catalog/listtypes' ); |
|
| 70 | + $this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/catalog/listtypes'); |
|
| 71 | 71 | |
| 72 | - $this->cache = $this->getCache( 'catalog' ); |
|
| 72 | + $this->cache = $this->getCache('catalog'); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | |
@@ -80,11 +80,11 @@ discard block |
||
| 80 | 80 | * @param array $data List of CSV fields with position as key and data as value |
| 81 | 81 | * @return array List of data which hasn't been imported |
| 82 | 82 | */ |
| 83 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
| 83 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
| 84 | 84 | { |
| 85 | 85 | $context = $this->getContext(); |
| 86 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'catalog' ); |
|
| 87 | - $listManager = \Aimeos\MShop\Factory::createManager( $context, 'catalog/lists' ); |
|
| 86 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'catalog'); |
|
| 87 | + $listManager = \Aimeos\MShop\Factory::createManager($context, 'catalog/lists'); |
|
| 88 | 88 | |
| 89 | 89 | /** controller/common/product/import/csv/separator |
| 90 | 90 | * Single separator character for multiple entries in one field of the import file |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @category Developer |
| 105 | 105 | * @see controller/common/product/import/csv/domains |
| 106 | 106 | */ |
| 107 | - $separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" ); |
|
| 107 | + $separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n"); |
|
| 108 | 108 | |
| 109 | 109 | $manager->begin(); |
| 110 | 110 | |
@@ -112,57 +112,57 @@ discard block |
||
| 112 | 112 | { |
| 113 | 113 | $listMap = []; |
| 114 | 114 | $prodid = $product->getId(); |
| 115 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
| 116 | - $listItems = $this->getListItems( $prodid, $this->listTypes ); |
|
| 115 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
| 116 | + $listItems = $this->getListItems($prodid, $this->listTypes); |
|
| 117 | 117 | |
| 118 | - foreach( $listItems as $listItem ) { |
|
| 119 | - $listMap[ $listItem->getParentId() ][ $listItem->getType() ] = $listItem; |
|
| 118 | + foreach ($listItems as $listItem) { |
|
| 119 | + $listMap[$listItem->getParentId()][$listItem->getType()] = $listItem; |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - foreach( $map as $pos => $list ) |
|
| 122 | + foreach ($map as $pos => $list) |
|
| 123 | 123 | { |
| 124 | - if( $this->checkEntry( $list ) === false ) { |
|
| 124 | + if ($this->checkEntry($list) === false) { |
|
| 125 | 125 | continue; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $codes = explode( $separator, trim( $list['catalog.code'] ) ); |
|
| 129 | - $type = trim( isset( $list['catalog.lists.type'] ) ? $list['catalog.lists.type'] : 'default' ); |
|
| 128 | + $codes = explode($separator, trim($list['catalog.code'])); |
|
| 129 | + $type = trim(isset($list['catalog.lists.type']) ? $list['catalog.lists.type'] : 'default'); |
|
| 130 | 130 | |
| 131 | - foreach( $codes as $code ) |
|
| 131 | + foreach ($codes as $code) |
|
| 132 | 132 | { |
| 133 | - $code = trim( $code ); |
|
| 133 | + $code = trim($code); |
|
| 134 | 134 | |
| 135 | - if( ( $catid = $this->cache->get( $code ) ) === null ) |
|
| 135 | + if (($catid = $this->cache->get($code)) === null) |
|
| 136 | 136 | { |
| 137 | 137 | $msg = 'No category for code "%1$s" available when importing product with code "%2$s"'; |
| 138 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( $msg, $code, $product->getCode() ) ); |
|
| 138 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf($msg, $code, $product->getCode())); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $list['catalog.lists.parentid'] = $catid; |
| 142 | 142 | $list['catalog.lists.refid'] = $prodid; |
| 143 | 143 | $list['catalog.lists.domain'] = 'product'; |
| 144 | 144 | |
| 145 | - if( isset( $listMap[$catid][$type] ) ) |
|
| 145 | + if (isset($listMap[$catid][$type])) |
|
| 146 | 146 | { |
| 147 | 147 | $listItem = $listMap[$catid][$type]; |
| 148 | - unset( $listItems[ $listItem->getId() ] ); |
|
| 148 | + unset($listItems[$listItem->getId()]); |
|
| 149 | 149 | } |
| 150 | 150 | else |
| 151 | 151 | { |
| 152 | - $listItem = $listManager->createItem( $type, 'product' ); |
|
| 152 | + $listItem = $listManager->createItem($type, 'product'); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - $listItem->fromArray( $this->addListItemDefaults( $list, $pos++ ) ); |
|
| 156 | - $listManager->saveItem( $listItem, false ); |
|
| 155 | + $listItem->fromArray($this->addListItemDefaults($list, $pos++)); |
|
| 156 | + $listManager->saveItem($listItem, false); |
|
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - $listManager->deleteItems( array_keys( $listItems ) ); |
|
| 161 | - $data = $this->getObject()->process( $product, $data ); |
|
| 160 | + $listManager->deleteItems(array_keys($listItems)); |
|
| 161 | + $data = $this->getObject()->process($product, $data); |
|
| 162 | 162 | |
| 163 | 163 | $manager->commit(); |
| 164 | 164 | } |
| 165 | - catch( \Exception $e ) |
|
| 165 | + catch (\Exception $e) |
|
| 166 | 166 | { |
| 167 | 167 | $manager->rollback(); |
| 168 | 168 | throw $e; |
@@ -179,13 +179,13 @@ discard block |
||
| 179 | 179 | * @param integer $pos Computed position of the list item in the associated list of items |
| 180 | 180 | * @return array Given associative list enriched by default values if they were not already set |
| 181 | 181 | */ |
| 182 | - protected function addListItemDefaults( array $list, $pos ) |
|
| 182 | + protected function addListItemDefaults(array $list, $pos) |
|
| 183 | 183 | { |
| 184 | - if( !isset( $list['catalog.lists.position'] ) ) { |
|
| 184 | + if (!isset($list['catalog.lists.position'])) { |
|
| 185 | 185 | $list['catalog.lists.position'] = $pos; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - if( !isset( $list['catalog.lists.status'] ) ) { |
|
| 188 | + if (!isset($list['catalog.lists.status'])) { |
|
| 189 | 189 | $list['catalog.lists.status'] = 1; |
| 190 | 190 | } |
| 191 | 191 | |
@@ -199,10 +199,10 @@ discard block |
||
| 199 | 199 | * @param array $list Associative list of key/value pairs from the mapped data |
| 200 | 200 | * @return boolean True if the entry is valid, false if not |
| 201 | 201 | */ |
| 202 | - protected function checkEntry( array $list ) |
|
| 202 | + protected function checkEntry(array $list) |
|
| 203 | 203 | { |
| 204 | - if( !isset( $list['catalog.code'] ) || trim( $list['catalog.code'] ) === '' || isset( $list['catalog.lists.type'] ) |
|
| 205 | - && $this->listTypes !== null && !in_array( trim( $list['catalog.lists.type'] ), (array) $this->listTypes ) |
|
| 204 | + if (!isset($list['catalog.code']) || trim($list['catalog.code']) === '' || isset($list['catalog.lists.type']) |
|
| 205 | + && $this->listTypes !== null && !in_array(trim($list['catalog.lists.type']), (array) $this->listTypes) |
|
| 206 | 206 | ) { |
| 207 | 207 | return false; |
| 208 | 208 | } |
@@ -218,24 +218,24 @@ discard block |
||
| 218 | 218 | * @param array|null $types List of catalog list types |
| 219 | 219 | * @return array List of catalog list items |
| 220 | 220 | */ |
| 221 | - protected function getListItems( $prodid, $types ) |
|
| 221 | + protected function getListItems($prodid, $types) |
|
| 222 | 222 | { |
| 223 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' ); |
|
| 223 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists'); |
|
| 224 | 224 | $search = $manager->createSearch(); |
| 225 | 225 | |
| 226 | 226 | $expr = array( |
| 227 | - $search->compare( '==', 'catalog.lists.domain', 'product' ), |
|
| 228 | - $search->compare( '==', 'catalog.lists.refid', $prodid ), |
|
| 227 | + $search->compare('==', 'catalog.lists.domain', 'product'), |
|
| 228 | + $search->compare('==', 'catalog.lists.refid', $prodid), |
|
| 229 | 229 | ); |
| 230 | 230 | |
| 231 | - if( $types !== null ) { |
|
| 232 | - $expr[] = $search->compare( '==', 'catalog.lists.type.code', $types ); |
|
| 231 | + if ($types !== null) { |
|
| 232 | + $expr[] = $search->compare('==', 'catalog.lists.type.code', $types); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 236 | - $search->setSortations( array( $search->sort( '+', 'catalog.lists.position' ) ) ); |
|
| 237 | - $search->setSlice( 0, 0x7FFFFFFF ); |
|
| 235 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 236 | + $search->setSortations(array($search->sort('+', 'catalog.lists.position'))); |
|
| 237 | + $search->setSlice(0, 0x7FFFFFFF); |
|
| 238 | 238 | |
| 239 | - return $manager->searchItems( $search ); |
|
| 239 | + return $manager->searchItems($search); |
|
| 240 | 240 | } |
| 241 | 241 | } |
@@ -146,8 +146,7 @@ discard block |
||
| 146 | 146 | { |
| 147 | 147 | $listItem = $listMap[$catid][$type]; |
| 148 | 148 | unset( $listItems[ $listItem->getId() ] ); |
| 149 | - } |
|
| 150 | - else |
|
| 149 | + } else |
|
| 151 | 150 | { |
| 152 | 151 | $listItem = $listManager->createItem( $type, 'product' ); |
| 153 | 152 | } |
@@ -161,8 +160,7 @@ discard block |
||
| 161 | 160 | $data = $this->getObject()->process( $product, $data ); |
| 162 | 161 | |
| 163 | 162 | $manager->commit(); |
| 164 | - } |
|
| 165 | - catch( \Exception $e ) |
|
| 163 | + } catch( \Exception $e ) |
|
| 166 | 164 | { |
| 167 | 165 | $manager->rollback(); |
| 168 | 166 | throw $e; |
@@ -42,10 +42,10 @@ 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 | 50 | /** controller/common/product/import/csv/processor/text/listtypes |
| 51 | 51 | * Names of the product list types for texts that are updated or removed |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * @see controller/common/product/import/csv/processor/price/listtypes |
| 67 | 67 | * @see controller/common/product/import/csv/processor/product/listtypes |
| 68 | 68 | */ |
| 69 | - $this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/text/listtypes' ); |
|
| 69 | + $this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/text/listtypes'); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | |
@@ -77,53 +77,53 @@ discard block |
||
| 77 | 77 | * @param array $data List of CSV fields with position as key and data as value |
| 78 | 78 | * @return array List of data which hasn't been imported |
| 79 | 79 | */ |
| 80 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
| 80 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
| 81 | 81 | { |
| 82 | - $listManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' ); |
|
| 83 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'text' ); |
|
| 82 | + $listManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists'); |
|
| 83 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'text'); |
|
| 84 | 84 | |
| 85 | 85 | $listMap = []; |
| 86 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
| 87 | - $listItems = $product->getListItems( 'text', $this->listTypes ); |
|
| 86 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
| 87 | + $listItems = $product->getListItems('text', $this->listTypes); |
|
| 88 | 88 | |
| 89 | - foreach( $listItems as $listItem ) |
|
| 89 | + foreach ($listItems as $listItem) |
|
| 90 | 90 | { |
| 91 | - if( ( $refItem = $listItem->getRefItem() ) !== null ) { |
|
| 92 | - $listMap[ $refItem->getContent() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem; |
|
| 91 | + if (($refItem = $listItem->getRefItem()) !== null) { |
|
| 92 | + $listMap[$refItem->getContent()][$refItem->getType()][$listItem->getType()] = $listItem; |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - foreach( $map as $pos => $list ) |
|
| 96 | + foreach ($map as $pos => $list) |
|
| 97 | 97 | { |
| 98 | - if( $this->checkEntry( $list ) === false ) { |
|
| 98 | + if ($this->checkEntry($list) === false) { |
|
| 99 | 99 | continue; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - $content = trim( $list['text.content'] ); |
|
| 103 | - $type = trim( isset( $list['text.type'] ) ? $list['text.type'] : 'name' ); |
|
| 104 | - $typecode = trim( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' ); |
|
| 102 | + $content = trim($list['text.content']); |
|
| 103 | + $type = trim(isset($list['text.type']) ? $list['text.type'] : 'name'); |
|
| 104 | + $typecode = trim(isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default'); |
|
| 105 | 105 | |
| 106 | - if( isset( $listMap[$content][$type][$typecode] ) ) |
|
| 106 | + if (isset($listMap[$content][$type][$typecode])) |
|
| 107 | 107 | { |
| 108 | 108 | $listItem = $listMap[$content][$type][$typecode]; |
| 109 | 109 | $refItem = $listItem->getRefItem(); |
| 110 | - unset( $listItems[ $listItem->getId() ] ); |
|
| 110 | + unset($listItems[$listItem->getId()]); |
|
| 111 | 111 | } |
| 112 | 112 | else |
| 113 | 113 | { |
| 114 | - $listItem = $listManager->createItem( $typecode, 'text' ); |
|
| 115 | - $refItem = $manager->createItem( $type, 'product' ); |
|
| 114 | + $listItem = $listManager->createItem($typecode, 'text'); |
|
| 115 | + $refItem = $manager->createItem($type, 'product'); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - $refItem->fromArray( $this->addItemDefaults( $list ) ); |
|
| 119 | - $listItem->fromArray( $this->addListItemDefaults( $list, $pos ) ); |
|
| 118 | + $refItem->fromArray($this->addItemDefaults($list)); |
|
| 119 | + $listItem->fromArray($this->addListItemDefaults($list, $pos)); |
|
| 120 | 120 | |
| 121 | - $product->addListItem( 'text', $listItem, $refItem ); |
|
| 121 | + $product->addListItem('text', $listItem, $refItem); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - $product->deleteListItems( $listItems, true ); |
|
| 124 | + $product->deleteListItems($listItems, true); |
|
| 125 | 125 | |
| 126 | - return $this->getObject()->process( $product, $data ); |
|
| 126 | + return $this->getObject()->process($product, $data); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | |
@@ -133,13 +133,13 @@ discard block |
||
| 133 | 133 | * @param array $list Associative list of domain item keys and their values, e.g. "text.status" => 1 |
| 134 | 134 | * @return array Given associative list enriched by default values if they were not already set |
| 135 | 135 | */ |
| 136 | - protected function addItemDefaults( array $list ) |
|
| 136 | + protected function addItemDefaults(array $list) |
|
| 137 | 137 | { |
| 138 | - if( !isset( $list['text.label'] ) ) { |
|
| 139 | - $list['text.label'] = mb_strcut( trim( $list['text.content'] ), 0, 255 ); |
|
| 138 | + if (!isset($list['text.label'])) { |
|
| 139 | + $list['text.label'] = mb_strcut(trim($list['text.content']), 0, 255); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - if( !isset( $list['text.status'] ) ) { |
|
| 142 | + if (!isset($list['text.status'])) { |
|
| 143 | 143 | $list['text.status'] = 1; |
| 144 | 144 | } |
| 145 | 145 | |
@@ -153,10 +153,10 @@ discard block |
||
| 153 | 153 | * @param array $list Associative list of key/value pairs from the mapping |
| 154 | 154 | * @return boolean True if valid, false if not |
| 155 | 155 | */ |
| 156 | - protected function checkEntry( array $list ) |
|
| 156 | + protected function checkEntry(array $list) |
|
| 157 | 157 | { |
| 158 | - if( !isset( $list['text.content'] ) || trim( $list['text.content'] ) === '' || isset( $list['product.lists.type'] ) |
|
| 159 | - && $this->listTypes !== null && !in_array( trim( $list['product.lists.type'] ), (array) $this->listTypes ) |
|
| 158 | + if (!isset($list['text.content']) || trim($list['text.content']) === '' || isset($list['product.lists.type']) |
|
| 159 | + && $this->listTypes !== null && !in_array(trim($list['product.lists.type']), (array) $this->listTypes) |
|
| 160 | 160 | ) { |
| 161 | 161 | return false; |
| 162 | 162 | } |
@@ -108,8 +108,7 @@ |
||
| 108 | 108 | $listItem = $listMap[$content][$type][$typecode]; |
| 109 | 109 | $refItem = $listItem->getRefItem(); |
| 110 | 110 | unset( $listItems[ $listItem->getId() ] ); |
| 111 | - } |
|
| 112 | - else |
|
| 111 | + } else |
|
| 113 | 112 | { |
| 114 | 113 | $listItem = $listManager->createItem( $typecode, 'text' ); |
| 115 | 114 | $refItem = $manager->createItem( $type, 'product' ); |