Completed
Branch master (14839e)
by Aimeos
03:29
created
src/Controller/Common/Product/Import/Csv/Processor/Stock/Standard.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
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
-		$this->cache = $this->getCache( 'warehouse' );
50
+		$this->cache = $this->getCache('warehouse');
51 51
 	}
52 52
 
53 53
 
@@ -58,55 +58,55 @@  discard block
 block discarded – undo
58 58
 	 * @param array $data List of CSV fields with position as key and data as value
59 59
 	 * @return array List of data which hasn't been imported
60 60
 	 */
61
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
61
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
62 62
 	{
63
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/stock' );
63
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/stock');
64 64
 		$manager->begin();
65 65
 
66 66
 		try
67 67
 		{
68 68
 			$pos = 0;
69 69
 			$delete = array();
70
-			$map = $this->getMappedChunk( $data );
71
-			$items = $this->getStockItems( $product->getId() );
70
+			$map = $this->getMappedChunk($data);
71
+			$items = $this->getStockItems($product->getId());
72 72
 
73
-			foreach( $map as $pos => $list )
73
+			foreach ($map as $pos => $list)
74 74
 			{
75
-				if( !array_key_exists( 'product.stock.stocklevel', $list ) ) {
75
+				if (!array_key_exists('product.stock.stocklevel', $list)) {
76 76
 					continue;
77 77
 				}
78 78
 
79
-				$whcode = ( isset( $list['product.stock.warehouse'] ) ? $list['product.stock.warehouse'] : 'default' );
79
+				$whcode = (isset($list['product.stock.warehouse']) ? $list['product.stock.warehouse'] : 'default');
80 80
 
81
-				if( !isset( $list['product.stock.warehouseid'] ) ) {
82
-					$list['product.stock.warehouseid'] = $this->cache->get( $whcode );
81
+				if (!isset($list['product.stock.warehouseid'])) {
82
+					$list['product.stock.warehouseid'] = $this->cache->get($whcode);
83 83
 				}
84 84
 
85
-				if( isset( $list['product.stock.dateback'] ) && $list['product.stock.dateback'] === '' ) {
85
+				if (isset($list['product.stock.dateback']) && $list['product.stock.dateback'] === '') {
86 86
 					$list['product.stock.dateback'] = null;
87 87
 				}
88 88
 
89
-				if( $list['product.stock.stocklevel'] === '' ) {
89
+				if ($list['product.stock.stocklevel'] === '') {
90 90
 					$list['product.stock.stocklevel'] = null;
91 91
 				}
92 92
 
93 93
 				$list['product.stock.parentid'] = $product->getId();
94 94
 
95
-				if( ( $item = array_pop( $items ) ) === null ) {
95
+				if (($item = array_pop($items)) === null) {
96 96
 					$item = $manager->createItem();
97 97
 				}
98 98
 
99
-				$item->fromArray( $list );
100
-				$manager->saveItem( $item );
99
+				$item->fromArray($list);
100
+				$manager->saveItem($item);
101 101
 			}
102 102
 
103
-			$manager->deleteItems( array_keys( $items ) );
103
+			$manager->deleteItems(array_keys($items));
104 104
 
105
-			$remaining = $this->getObject()->process( $product, $data );
105
+			$remaining = $this->getObject()->process($product, $data);
106 106
 
107 107
 			$manager->commit();
108 108
 		}
109
-		catch( \Exception $e )
109
+		catch (\Exception $e)
110 110
 		{
111 111
 			$manager->rollback();
112 112
 			throw $e;
@@ -122,13 +122,13 @@  discard block
 block discarded – undo
122 122
 	 * @param string $prodid Unique product ID
123 123
 	 * @return array Associative list of product stock items
124 124
 	 */
125
-	protected function getStockItems( $prodid )
125
+	protected function getStockItems($prodid)
126 126
 	{
127
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/stock' );
127
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/stock');
128 128
 
129 129
 		$search = $manager->createSearch();
130
-		$search->setConditions( $search->compare( '==', 'product.stock.parentid', $prodid ) );
130
+		$search->setConditions($search->compare('==', 'product.stock.parentid', $prodid));
131 131
 
132
-		return $manager->searchItems( $search );
132
+		return $manager->searchItems($search);
133 133
 	}
134 134
 }
Please login to merge, or discard this patch.
common/src/Controller/Common/Product/Import/Csv/Processor/Done.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
28 28
 	 * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor Decorated processor
29 29
 	 */
30
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
31
-		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor = null )
30
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
31
+		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor = null)
32 32
 	{
33 33
 	}
34 34
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
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 45
 		return $data;
46 46
 	}
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Attribute/Standard.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
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/attribute/listtypes
52 52
 		 * Names of the product list types for attributes that are updated or removed
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 		 * @see controller/common/product/import/csv/processor/price/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/attribute/listtypes');
70
+		$this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/attribute/listtypes');
71 71
 
72
-		$this->cache = $this->getCache( 'attribute' );
72
+		$this->cache = $this->getCache('attribute');
73 73
 	}
74 74
 
75 75
 
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
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, 'attribute' );
87
-		$listManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' );
88
-		$separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" );
86
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'attribute');
87
+		$listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists');
88
+		$separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n");
89 89
 
90 90
 		$manager->begin();
91 91
 
@@ -93,25 +93,25 @@  discard block
 block discarded – undo
93 93
 		{
94 94
 			$pos = 0;
95 95
 			$delete = $attrcodes = array();
96
-			$map = $this->getMappedChunk( $data );
97
-			$listItems = $product->getListItems( 'attribute', $this->listTypes );
96
+			$map = $this->getMappedChunk($data);
97
+			$listItems = $product->getListItems('attribute', $this->listTypes);
98 98
 
99
-			foreach( $listItems as $listId => $listItem )
99
+			foreach ($listItems as $listId => $listItem)
100 100
 			{
101
-				if( isset( $map[$pos] ) )
101
+				if (isset($map[$pos]))
102 102
 				{
103
-					if( !isset( $map[$pos]['attribute.code'] ) || !isset( $map[$pos]['attribute.type'] ) )
103
+					if (!isset($map[$pos]['attribute.code']) || !isset($map[$pos]['attribute.type']))
104 104
 					{
105
-						unset( $map[$pos] );
105
+						unset($map[$pos]);
106 106
 						continue;
107 107
 					}
108 108
 
109 109
 					$refItem = $listItem->getRefItem();
110 110
 
111
-					if( $refItem !== null && $map[$pos]['attribute.code'] === $refItem->getCode()
111
+					if ($refItem !== null && $map[$pos]['attribute.code'] === $refItem->getCode()
112 112
 						&& $map[$pos]['attribute.type'] === $refItem->getType()
113
-						&& ( !isset( $map[$pos]['product.lists.type'] ) || isset( $map[$pos]['product.lists.type'] )
114
-						&& $map[$pos]['product.lists.type'] === $listItem->getType() )
113
+						&& (!isset($map[$pos]['product.lists.type']) || isset($map[$pos]['product.lists.type'])
114
+						&& $map[$pos]['product.lists.type'] === $listItem->getType())
115 115
 					) {
116 116
 						$pos++;
117 117
 						continue;
@@ -123,46 +123,46 @@  discard block
 block discarded – undo
123 123
 				$pos++;
124 124
 			}
125 125
 
126
-			$listManager->deleteItems( $delete );
126
+			$listManager->deleteItems($delete);
127 127
 
128
-			foreach( $map as $pos => $list )
128
+			foreach ($map as $pos => $list)
129 129
 			{
130
-				if( !isset( $list['attribute.code'] ) || $list['attribute.code'] === '' || $list['attribute.type'] === ''
131
-					|| isset( $list['product.lists.type'] ) && $this->listTypes !== null
132
-					&& !in_array( $list['product.lists.type'], (array) $this->listTypes )
130
+				if (!isset($list['attribute.code']) || $list['attribute.code'] === '' || $list['attribute.type'] === ''
131
+					|| isset($list['product.lists.type']) && $this->listTypes !== null
132
+					&& !in_array($list['product.lists.type'], (array) $this->listTypes)
133 133
 				) {
134 134
 					continue;
135 135
 				}
136 136
 
137
-				$codes = explode( $separator, $list['attribute.code'] );
137
+				$codes = explode($separator, $list['attribute.code']);
138 138
 
139
-				foreach( $codes as $code )
139
+				foreach ($codes as $code)
140 140
 				{
141
-					$attrItem = $this->getAttributeItem( $code, $list['attribute.type'] );
142
-					$attrItem->fromArray( $list );
143
-					$attrItem->setCode( $code );
144
-					$manager->saveItem( $attrItem );
141
+					$attrItem = $this->getAttributeItem($code, $list['attribute.type']);
142
+					$attrItem->fromArray($list);
143
+					$attrItem->setCode($code);
144
+					$manager->saveItem($attrItem);
145 145
 
146
-					if( ( $listItem = array_shift( $listItems ) ) === null ) {
146
+					if (($listItem = array_shift($listItems)) === null) {
147 147
 						$listItem = $listManager->createItem();
148 148
 					}
149 149
 
150
-					$typecode = ( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' );
151
-					$list['product.lists.typeid'] = $this->getTypeId( 'product/lists/type', 'attribute', $typecode );
150
+					$typecode = (isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default');
151
+					$list['product.lists.typeid'] = $this->getTypeId('product/lists/type', 'attribute', $typecode);
152 152
 					$list['product.lists.refid'] = $attrItem->getId();
153 153
 					$list['product.lists.parentid'] = $product->getId();
154 154
 					$list['product.lists.domain'] = 'attribute';
155 155
 
156
-					$listItem->fromArray( $this->addListItemDefaults( $list, $pos ) );
157
-					$listManager->saveItem( $listItem );
156
+					$listItem->fromArray($this->addListItemDefaults($list, $pos));
157
+					$listManager->saveItem($listItem);
158 158
 				}
159 159
 			}
160 160
 
161
-			$remaining = $this->getObject()->process( $product, $data );
161
+			$remaining = $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,21 +179,21 @@  discard block
 block discarded – undo
179 179
 	 * @param string $type Attribute type
180 180
 	 * @return \Aimeos\MShop\Attribute\Item\Iface Attribute item object
181 181
 	 */
182
-	protected function getAttributeItem( $code, $type )
182
+	protected function getAttributeItem($code, $type)
183 183
 	{
184
-		if( ( $item = $this->cache->get( $code, $type ) ) === null )
184
+		if (($item = $this->cache->get($code, $type)) === null)
185 185
 		{
186
-			$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' );
186
+			$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute');
187 187
 
188 188
 			$item = $manager->createItem();
189
-			$item->setTypeId( $this->getTypeId( 'attribute/type', 'product', $type ) );
190
-			$item->setCode( $code );
191
-			$item->setLabel( $type . ' ' . $code );
192
-			$item->setStatus( 1 );
189
+			$item->setTypeId($this->getTypeId('attribute/type', 'product', $type));
190
+			$item->setCode($code);
191
+			$item->setLabel($type . ' ' . $code);
192
+			$item->setStatus(1);
193 193
 
194
-			$manager->saveItem( $item );
194
+			$manager->saveItem($item);
195 195
 
196
-			$this->cache->set( $item );
196
+			$this->cache->set($item);
197 197
 		}
198 198
 
199 199
 		return $item;
Please login to merge, or discard this patch.
common/src/Controller/Common/Product/Import/Csv/Processor/Iface.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
27 27
 	 * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor Decorated processor
28 28
 	 */
29
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
30
-		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor = null );
29
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
30
+		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor = null);
31 31
 
32 32
 
33 33
 	/**
@@ -37,5 +37,5 @@  discard block
 block discarded – undo
37 37
 	 * @param array $data List of CSV fields with position as key and data as value
38 38
 	 * @return array List of data which hasn't been imported
39 39
 	 */
40
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data );
40
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data);
41 41
 }
42 42
\ No newline at end of file
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Catalog/Standard.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,54 +104,54 @@  discard block
 block discarded – undo
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
 
111 111
 		try
112 112
 		{
113 113
 			$prodid = $product->getId();
114
-			$map = $this->getMappedChunk( $data );
115
-			$listItems = $this->getListItemPool( $product, $map );
114
+			$map = $this->getMappedChunk($data);
115
+			$listItems = $this->getListItemPool($product, $map);
116 116
 
117
-			foreach( $map as $pos => $list )
117
+			foreach ($map as $pos => $list)
118 118
 			{
119
-				if( !isset( $list['catalog.code'] ) || $list['catalog.code'] === '' || isset( $list['catalog.lists.type'] )
120
-					&& $this->listTypes !== null && !in_array( $list['catalog.lists.type'], (array) $this->listTypes )
119
+				if (!isset($list['catalog.code']) || $list['catalog.code'] === '' || isset($list['catalog.lists.type'])
120
+					&& $this->listTypes !== null && !in_array($list['catalog.lists.type'], (array) $this->listTypes)
121 121
 				) {
122 122
 					continue;
123 123
 				}
124 124
 
125
-				$codes = explode( $separator, $list['catalog.code'] );
126
-				$type = ( isset( $list['catalog.lists.type'] ) ? $list['catalog.lists.type'] : 'default' );
125
+				$codes = explode($separator, $list['catalog.code']);
126
+				$type = (isset($list['catalog.lists.type']) ? $list['catalog.lists.type'] : 'default');
127 127
 
128
-				foreach( $codes as $code )
128
+				foreach ($codes as $code)
129 129
 				{
130
-					if( ( $catid = $this->cache->get( $code ) ) === null )
130
+					if (($catid = $this->cache->get($code)) === null)
131 131
 					{
132 132
 						$msg = 'No category for code "%1$s" available when importing product with code "%2$s"';
133
-						throw new \Aimeos\Controller\Jobs\Exception( sprintf( $msg, $code, $product->getCode() ) );
133
+						throw new \Aimeos\Controller\Jobs\Exception(sprintf($msg, $code, $product->getCode()));
134 134
 					}
135 135
 
136
-					if( ( $listItem = array_shift( $listItems ) ) === null ) {
136
+					if (($listItem = array_shift($listItems)) === null) {
137 137
 						$listItem = $listManager->createItem();
138 138
 					}
139 139
 
140
-					$list['catalog.lists.typeid'] = $this->getTypeId( 'catalog/lists/type', 'product', $type );
140
+					$list['catalog.lists.typeid'] = $this->getTypeId('catalog/lists/type', 'product', $type);
141 141
 					$list['catalog.lists.parentid'] = $catid;
142 142
 					$list['catalog.lists.refid'] = $prodid;
143 143
 					$list['catalog.lists.domain'] = 'product';
144 144
 
145
-					$listItem->fromArray( $this->addListItemDefaults( $list, $pos++ ) );
146
-					$listManager->saveItem( $listItem );
145
+					$listItem->fromArray($this->addListItemDefaults($list, $pos++));
146
+					$listManager->saveItem($listItem);
147 147
 				}
148 148
 			}
149 149
 
150
-			$remaining = $this->getObject()->process( $product, $data );
150
+			$remaining = $this->getObject()->process($product, $data);
151 151
 
152 152
 			$manager->commit();
153 153
 		}
154
-		catch( \Exception $e )
154
+		catch (\Exception $e)
155 155
 		{
156 156
 			$manager->rollback();
157 157
 			throw $e;
@@ -168,13 +168,13 @@  discard block
 block discarded – undo
168 168
 	 * @param integer $pos Computed position of the list item in the associated list of items
169 169
 	 * @return array Given associative list enriched by default values if they were not already set
170 170
 	 */
171
-	protected function addListItemDefaults( array $list, $pos )
171
+	protected function addListItemDefaults(array $list, $pos)
172 172
 	{
173
-		if( !isset( $list['catalog.lists.position'] ) ) {
173
+		if (!isset($list['catalog.lists.position'])) {
174 174
 			$list['catalog.lists.position'] = $pos;
175 175
 		}
176 176
 
177
-		if( !isset( $list['catalog.lists.status'] ) ) {
177
+		if (!isset($list['catalog.lists.status'])) {
178 178
 			$list['catalog.lists.status'] = 1;
179 179
 		}
180 180
 
@@ -189,25 +189,25 @@  discard block
 block discarded – undo
189 189
 	 * @param array|null $types List of catalog list types
190 190
 	 * @return array List of catalog list items
191 191
 	 */
192
-	protected function getListItems( $prodid, $types )
192
+	protected function getListItems($prodid, $types)
193 193
 	{
194
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' );
194
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists');
195 195
 		$search = $manager->createSearch();
196 196
 
197 197
 		$expr = array(
198
-			$search->compare( '==', 'catalog.lists.domain', 'product' ),
199
-			$search->compare( '==', 'catalog.lists.refid', $prodid ),
198
+			$search->compare('==', 'catalog.lists.domain', 'product'),
199
+			$search->compare('==', 'catalog.lists.refid', $prodid),
200 200
 		);
201 201
 
202
-		if( $types !== null ) {
203
-			$expr[] = $search->compare( '==', 'catalog.lists.type.code', $types );
202
+		if ($types !== null) {
203
+			$expr[] = $search->compare('==', 'catalog.lists.type.code', $types);
204 204
 		}
205 205
 
206
-		$search->setConditions( $search->combine( '&&', $expr ) );
207
-		$search->setSortations( array( $search->sort( '+', 'catalog.lists.position' ) ) );
208
-		$search->setSlice( 0, 0x7FFFFFFF );
206
+		$search->setConditions($search->combine('&&', $expr));
207
+		$search->setSortations(array($search->sort('+', 'catalog.lists.position')));
208
+		$search->setSlice(0, 0x7FFFFFFF);
209 209
 
210
-		return $manager->searchItems( $search );
210
+		return $manager->searchItems($search);
211 211
 	}
212 212
 
213 213
 
@@ -218,16 +218,16 @@  discard block
 block discarded – undo
218 218
 	 * @param array $map List of associative arrays containing the chunked properties
219 219
 	 * @return array List of list items implementing \Aimeos\MShop\Common\Item\Lists\Iface
220 220
 	 */
221
-	protected function getListItemPool( \Aimeos\MShop\Product\Item\Iface $product, array $map )
221
+	protected function getListItemPool(\Aimeos\MShop\Product\Item\Iface $product, array $map)
222 222
 	{
223 223
 		$pos = 0;
224 224
 		$delete = array();
225
-		$listItems = $this->getListItems( $product->getId(), $this->listTypes );
225
+		$listItems = $this->getListItems($product->getId(), $this->listTypes);
226 226
 
227
-		foreach( $listItems as $listId => $listItem )
227
+		foreach ($listItems as $listId => $listItem)
228 228
 		{
229
-			if( isset( $map[$pos] ) && ( !isset( $map[$pos]['catalog.code'] )
230
-				|| $this->cache->get( $map[$pos]['catalog.code'] ) == $listItem->getParentId() )
229
+			if (isset($map[$pos]) && (!isset($map[$pos]['catalog.code'])
230
+				|| $this->cache->get($map[$pos]['catalog.code']) == $listItem->getParentId())
231 231
 			) {
232 232
 				$pos++;
233 233
 				continue;
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
 			$pos++;
239 239
 		}
240 240
 
241
-		$listManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' );
242
-		$listManager->deleteItems( $delete );
241
+		$listManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists');
242
+		$listManager->deleteItems($delete);
243 243
 
244 244
 		return $listItems;
245 245
 	}
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Media/Standard.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,71 +77,71 @@  discard block
 block discarded – undo
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
 		$manager->begin();
88 88
 
89 89
 		try
90 90
 		{
91
-			$map = $this->getMappedChunk( $data );
92
-			$listItems = $product->getListItems( 'media' );
91
+			$map = $this->getMappedChunk($data);
92
+			$listItems = $product->getListItems('media');
93 93
 
94
-			foreach( $map as $pos => $list )
94
+			foreach ($map as $pos => $list)
95 95
 			{
96
-				if( !isset( $list['media.url'] ) || $list['media.url'] === '' || isset( $list['product.lists.type'] )
97
-					&& $this->listTypes !== null && !in_array( $list['product.lists.type'], (array) $this->listTypes )
96
+				if (!isset($list['media.url']) || $list['media.url'] === '' || isset($list['product.lists.type'])
97
+					&& $this->listTypes !== null && !in_array($list['product.lists.type'], (array) $this->listTypes)
98 98
 				) {
99 99
 					continue;
100 100
 				}
101 101
 
102
-				$urls = explode( $separator, $list['media.url'] );
103
-				$type = ( isset( $list['media.type'] ) ? $list['media.type'] : 'default' );
104
-				$typecode = ( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' );
105
-				$langid = ( isset( $list['media.languageid'] ) && $list['media.languageid'] !== '' ? $list['media.languageid'] : null );
102
+				$urls = explode($separator, $list['media.url']);
103
+				$type = (isset($list['media.type']) ? $list['media.type'] : 'default');
104
+				$typecode = (isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default');
105
+				$langid = (isset($list['media.languageid']) && $list['media.languageid'] !== '' ? $list['media.languageid'] : null);
106 106
 
107
-				foreach( $urls as $url )
107
+				foreach ($urls as $url)
108 108
 				{
109
-					if( ( $listItem = array_shift( $listItems ) ) !== null ) {
109
+					if (($listItem = array_shift($listItems)) !== null) {
110 110
 						$refItem = $listItem->getRefItem();
111 111
 					} else {
112 112
 						$listItem = $listManager->createItem();
113 113
 						$refItem = $manager->createItem();
114 114
 					}
115 115
 
116
-					$list['media.typeid'] = $this->getTypeId( 'media/type', 'product', $type );
116
+					$list['media.typeid'] = $this->getTypeId('media/type', 'product', $type);
117 117
 					$list['media.languageid'] = $langid;
118 118
 					$list['media.domain'] = 'product';
119 119
 					$list['media.url'] = $url;
120 120
 
121
-					$refItem->fromArray( $this->addItemDefaults( $list ) );
122
-					$manager->saveItem( $refItem );
121
+					$refItem->fromArray($this->addItemDefaults($list));
122
+					$manager->saveItem($refItem);
123 123
 
124
-					$list['product.lists.typeid'] = $this->getTypeId( 'product/lists/type', 'media', $typecode );
124
+					$list['product.lists.typeid'] = $this->getTypeId('product/lists/type', 'media', $typecode);
125 125
 					$list['product.lists.parentid'] = $product->getId();
126 126
 					$list['product.lists.refid'] = $refItem->getId();
127 127
 					$list['product.lists.domain'] = 'media';
128 128
 
129
-					$listItem->fromArray( $this->addListItemDefaults( $list, $pos++ ) );
130
-					$listManager->saveItem( $listItem );
129
+					$listItem->fromArray($this->addListItemDefaults($list, $pos++));
130
+					$listManager->saveItem($listItem);
131 131
 				}
132 132
 			}
133 133
 
134
-			foreach( $listItems as $listItem )
134
+			foreach ($listItems as $listItem)
135 135
 			{
136
-				$manager->deleteItem( $listItem->getRefItem()->getId() );
137
-				$listManager->deleteItem( $listItem->getId() );
136
+				$manager->deleteItem($listItem->getRefItem()->getId());
137
+				$listManager->deleteItem($listItem->getId());
138 138
 			}
139 139
 
140
-			$remaining = $this->getObject()->process( $product, $data );
140
+			$remaining = $this->getObject()->process($product, $data);
141 141
 
142 142
 			$manager->commit();
143 143
 		}
144
-		catch( \Exception $e )
144
+		catch (\Exception $e)
145 145
 		{
146 146
 			$manager->rollback();
147 147
 			throw $e;
@@ -157,17 +157,17 @@  discard block
 block discarded – undo
157 157
 	 * @param array $list Associative list of domain item keys and their values, e.g. "media.status" => 1
158 158
 	 * @return array Given associative list enriched by default values if they were not already set
159 159
 	 */
160
-	protected function addItemDefaults( array $list )
160
+	protected function addItemDefaults(array $list)
161 161
 	{
162
-		if( !isset( $list['media.label'] ) ) {
162
+		if (!isset($list['media.label'])) {
163 163
 			$list['media.label'] = $list['media.url'];
164 164
 		}
165 165
 
166
-		if( !isset( $list['media.preview'] ) ) {
166
+		if (!isset($list['media.preview'])) {
167 167
 			$list['media.preview'] = $list['media.url'];
168 168
 		}
169 169
 
170
-		if( !isset( $list['media.status'] ) ) {
170
+		if (!isset($list['media.status'])) {
171 171
 			$list['media.status'] = 1;
172 172
 		}
173 173
 
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Price/Standard.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,60 +77,60 @@  discard block
 block discarded – undo
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
 		$manager->begin();
85 85
 
86 86
 		try
87 87
 		{
88
-			$listItems = $product->getListItems( 'price' );
89
-			$map = $this->getMappedChunk( $data );
88
+			$listItems = $product->getListItems('price');
89
+			$map = $this->getMappedChunk($data);
90 90
 
91
-			foreach( $map as $pos => $list )
91
+			foreach ($map as $pos => $list)
92 92
 			{
93
-				if( !isset( $list['price.value'] ) || $list['price.value'] === '' || isset( $list['product.lists.type'] )
94
-					&& $this->listTypes !== null && !in_array( $list['product.lists.type'], (array) $this->listTypes )
93
+				if (!isset($list['price.value']) || $list['price.value'] === '' || isset($list['product.lists.type'])
94
+					&& $this->listTypes !== null && !in_array($list['product.lists.type'], (array) $this->listTypes)
95 95
 				) {
96 96
 					continue;
97 97
 				}
98 98
 
99
-				if( ( $listItem = array_shift( $listItems ) ) !== null ) {
99
+				if (($listItem = array_shift($listItems)) !== null) {
100 100
 					$refItem = $listItem->getRefItem();
101 101
 				} else {
102 102
 					$listItem = $listManager->createItem();
103 103
 					$refItem = $manager->createItem();
104 104
 				}
105 105
 
106
-				$typecode = ( isset( $list['price.type'] ) ? $list['price.type'] : 'default' );
107
-				$list['price.typeid'] = $this->getTypeId( 'price/type', 'product', $typecode );
106
+				$typecode = (isset($list['price.type']) ? $list['price.type'] : 'default');
107
+				$list['price.typeid'] = $this->getTypeId('price/type', 'product', $typecode);
108 108
 				$list['price.domain'] = 'product';
109 109
 
110
-				$refItem->fromArray( $this->addItemDefaults( $list ) );
111
-				$manager->saveItem( $refItem );
110
+				$refItem->fromArray($this->addItemDefaults($list));
111
+				$manager->saveItem($refItem);
112 112
 
113
-				$typecode = ( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' );
114
-				$list['product.lists.typeid'] = $this->getTypeId( 'product/lists/type', 'price', $typecode );
113
+				$typecode = (isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default');
114
+				$list['product.lists.typeid'] = $this->getTypeId('product/lists/type', 'price', $typecode);
115 115
 				$list['product.lists.parentid'] = $product->getId();
116 116
 				$list['product.lists.refid'] = $refItem->getId();
117 117
 				$list['product.lists.domain'] = 'price';
118 118
 
119
-				$listItem->fromArray( $this->addListItemDefaults( $list, $pos ) );
120
-				$listManager->saveItem( $listItem );
119
+				$listItem->fromArray($this->addListItemDefaults($list, $pos));
120
+				$listManager->saveItem($listItem);
121 121
 			}
122 122
 
123
-			foreach( $listItems as $listItem )
123
+			foreach ($listItems as $listItem)
124 124
 			{
125
-				$manager->deleteItem( $listItem->getRefItem()->getId() );
126
-				$listManager->deleteItem( $listItem->getId() );
125
+				$manager->deleteItem($listItem->getRefItem()->getId());
126
+				$listManager->deleteItem($listItem->getId());
127 127
 			}
128 128
 
129
-			$remaining = $this->getObject()->process( $product, $data );
129
+			$remaining = $this->getObject()->process($product, $data);
130 130
 
131 131
 			$manager->commit();
132 132
 		}
133
-		catch( \Exception $e )
133
+		catch (\Exception $e)
134 134
 		{
135 135
 			$manager->rollback();
136 136
 			throw $e;
@@ -146,17 +146,17 @@  discard block
 block discarded – undo
146 146
 	 * @param array $list Associative list of domain item keys and their values, e.g. "price.status" => 1
147 147
 	 * @return array Given associative list enriched by default values if they were not already set
148 148
 	 */
149
-	protected function addItemDefaults( array $list )
149
+	protected function addItemDefaults(array $list)
150 150
 	{
151
-		if( !isset( $list['price.currencyid'] ) ) {
151
+		if (!isset($list['price.currencyid'])) {
152 152
 			$list['price.currencyid'] = $this->getContext()->getLocale()->getCurrencyId();
153 153
 		}
154 154
 
155
-		if( !isset( $list['price.label'] ) ) {
155
+		if (!isset($list['price.label'])) {
156 156
 			$list['price.label'] = $list['price.currencyid'] . ' ' . $list['price.value'];
157 157
 		}
158 158
 
159
-		if( !isset( $list['price.status'] ) ) {
159
+		if (!isset($list['price.status'])) {
160 160
 			$list['price.status'] = 1;
161 161
 		}
162 162
 
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Property/Standard.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -40,32 +40,32 @@  discard block
 block discarded – undo
40 40
 	 * @param array $data List of CSV fields with position as key and data as value
41 41
 	 * @return array List of data which hasn't been imported
42 42
 	 */
43
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
43
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
44 44
 	{
45
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/property' );
45
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/property');
46 46
 		$manager->begin();
47 47
 
48 48
 		try
49 49
 		{
50 50
 			$pos = 0;
51 51
 			$delete = array();
52
-			$map = $this->getMappedChunk( $data );
53
-			$items = $this->getPropertyItems( $product->getId() );
52
+			$map = $this->getMappedChunk($data);
53
+			$items = $this->getPropertyItems($product->getId());
54 54
 
55
-			foreach( $items as $id => $item )
55
+			foreach ($items as $id => $item)
56 56
 			{
57
-				if( isset( $map[$pos] ) )
57
+				if (isset($map[$pos]))
58 58
 				{
59
-					if( !isset( $map[$pos]['product.property.type'] ) || !isset( $map[$pos]['product.property.value'] ) )
59
+					if (!isset($map[$pos]['product.property.type']) || !isset($map[$pos]['product.property.value']))
60 60
 					{
61
-						unset( $map[$pos] );
61
+						unset($map[$pos]);
62 62
 						continue;
63 63
 					}
64 64
 
65
-					if( $map[$pos]['product.property.type'] === $item->getType()
65
+					if ($map[$pos]['product.property.type'] === $item->getType()
66 66
 						&& $map[$pos]['product.property.value'] === $item->getValue()
67
-						&& ( !isset( $map[$pos]['product.property.languageid'] )
68
-							|| isset( $map[$pos]['product.property.languageid'] )
67
+						&& (!isset($map[$pos]['product.property.languageid'])
68
+							|| isset($map[$pos]['product.property.languageid'])
69 69
 							&& $map[$pos]['product.property.languageid'] === $item->getLanguageId()
70 70
 						)
71 71
 					) {
@@ -79,31 +79,31 @@  discard block
 block discarded – undo
79 79
 				$pos++;
80 80
 			}
81 81
 
82
-			$manager->deleteItems( $delete );
82
+			$manager->deleteItems($delete);
83 83
 
84
-			foreach( $map as $pos => $list )
84
+			foreach ($map as $pos => $list)
85 85
 			{
86
-				if( $list['product.property.type'] == '' || $list['product.property.value'] == '' ) {
86
+				if ($list['product.property.type'] == '' || $list['product.property.value'] == '') {
87 87
 					continue;
88 88
 				}
89 89
 
90 90
 				$typecode = $list['product.property.type'];
91
-				$list['product.property.typeid'] = $this->getTypeId( 'product/property/type', 'product', $typecode );
91
+				$list['product.property.typeid'] = $this->getTypeId('product/property/type', 'product', $typecode);
92 92
 				$list['product.property.parentid'] = $product->getId();
93 93
 
94
-				if( ( $item = array_shift( $items ) ) === null ) {
94
+				if (($item = array_shift($items)) === null) {
95 95
 					$item = $manager->createItem();
96 96
 				}
97 97
 
98
-				$item->fromArray( $list );
99
-				$manager->saveItem( $item );
98
+				$item->fromArray($list);
99
+				$manager->saveItem($item);
100 100
 			}
101 101
 
102
-			$remaining = $this->getObject()->process( $product, $data );
102
+			$remaining = $this->getObject()->process($product, $data);
103 103
 
104 104
 			$manager->commit();
105 105
 		}
106
-		catch( \Exception $e )
106
+		catch (\Exception $e)
107 107
 		{
108 108
 			$manager->rollback();
109 109
 			throw $e;
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
 	 * @param string $prodid Unique product ID
120 120
 	 * @return array Associative list of product property items
121 121
 	 */
122
-	protected function getPropertyItems( $prodid )
122
+	protected function getPropertyItems($prodid)
123 123
 	{
124
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/property' );
124
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/property');
125 125
 
126 126
 		$search = $manager->createSearch();
127
-		$search->setConditions( $search->compare( '==', 'product.property.parentid', $prodid ) );
127
+		$search->setConditions($search->compare('==', 'product.property.parentid', $prodid));
128 128
 
129
-		return $manager->searchItems( $search );
129
+		return $manager->searchItems($search);
130 130
 	}
131 131
 }
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Product/Standard.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
73 73
 		 * @see controller/common/product/import/csv/processor/price/listtypes
74 74
 		 * @see controller/common/product/import/csv/processor/text/listtypes
75 75
 		 */
76
-		$default = array( 'default', 'suggestion' );
76
+		$default = array('default', 'suggestion');
77 77
 		$key = 'controller/common/product/import/csv/processor/product/listtypes';
78
-		$this->listTypes = $context->getConfig()->get( $key, $default );
78
+		$this->listTypes = $context->getConfig()->get($key, $default);
79 79
 
80
-		$this->cache = $this->getCache( 'product' );
80
+		$this->cache = $this->getCache('product');
81 81
 	}
82 82
 
83 83
 
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
 	 * @param array $data List of CSV fields with position as key and data as value
89 89
 	 * @return array List of data which hasn't been imported
90 90
 	 */
91
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
91
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
92 92
 	{
93 93
 		$context = $this->getContext();
94
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
95
-		$separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" );
94
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'product');
95
+		$separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n");
96 96
 
97
-		$this->cache->set( $product );
97
+		$this->cache->set($product);
98 98
 
99 99
 		$manager->begin();
100 100
 
@@ -102,39 +102,39 @@  discard block
 block discarded – undo
102 102
 		{
103 103
 			$types = array();
104 104
 
105
-			foreach( $this->getMappedChunk( $data ) as $list )
105
+			foreach ($this->getMappedChunk($data) as $list)
106 106
 			{
107
-				if( !isset( $list['product.code'] ) || $list['product.code'] === '' || isset( $list['product.lists.type'] )
108
-					&& $this->listTypes !== null && !in_array( $list['product.lists.type'], (array) $this->listTypes )
107
+				if (!isset($list['product.code']) || $list['product.code'] === '' || isset($list['product.lists.type'])
108
+					&& $this->listTypes !== null && !in_array($list['product.lists.type'], (array) $this->listTypes)
109 109
 				) {
110 110
 					continue;
111 111
 				}
112 112
 
113 113
 				$listMap = array();
114
-				$type = ( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' );
114
+				$type = (isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default');
115 115
 				$types[] = $type;
116 116
 
117
-				foreach( explode( $separator, $list['product.code'] ) as $code )
117
+				foreach (explode($separator, $list['product.code']) as $code)
118 118
 				{
119
-					if( ( $prodid = $this->cache->get( $code ) ) === null )
119
+					if (($prodid = $this->cache->get($code)) === null)
120 120
 					{
121 121
 						$msg = 'No product for code "%1$s" available when importing product with code "%2$s"';
122
-						throw new \Aimeos\Controller\Jobs\Exception( sprintf( $msg, $code, $product->getCode() ) );
122
+						throw new \Aimeos\Controller\Jobs\Exception(sprintf($msg, $code, $product->getCode()));
123 123
 					}
124 124
 
125 125
 					$listMap[$prodid] = $list;
126 126
 				}
127 127
 
128
-				$manager->updateListItems( $product, $listMap, 'product', $type );
128
+				$manager->updateListItems($product, $listMap, 'product', $type);
129 129
 			}
130 130
 
131
-			$this->deleteListItems( $product->getId(), $types );
131
+			$this->deleteListItems($product->getId(), $types);
132 132
 
133
-			$remaining = $this->getObject()->process( $product, $data );
133
+			$remaining = $this->getObject()->process($product, $data);
134 134
 
135 135
 			$manager->commit();
136 136
 		}
137
-		catch( \Exception $e )
137
+		catch (\Exception $e)
138 138
 		{
139 139
 			$manager->rollback();
140 140
 			throw $e;
@@ -150,19 +150,19 @@  discard block
 block discarded – undo
150 150
 	 * @param string $prodId Unique product ID
151 151
 	 * @param array $types List of types that have been updated
152 152
 	 */
153
-	protected function deleteListItems( $prodId, array $types )
153
+	protected function deleteListItems($prodId, array $types)
154 154
 	{
155
-		$codes = array_diff( $this->listTypes, $types );
156
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' );
155
+		$codes = array_diff($this->listTypes, $types);
156
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists');
157 157
 
158 158
 		$search = $manager->createSearch();
159 159
 		$expr = array(
160
-			$search->compare( '==', 'product.lists.parentid', $prodId ),
161
-			$search->compare( '==', 'product.lists.domain', 'product' ),
162
-			$search->compare( '==', 'product.lists.type.code', $codes ),
160
+			$search->compare('==', 'product.lists.parentid', $prodId),
161
+			$search->compare('==', 'product.lists.domain', 'product'),
162
+			$search->compare('==', 'product.lists.type.code', $codes),
163 163
 		);
164
-		$search->setConditions( $search->combine( '&&', $expr ) );
164
+		$search->setConditions($search->combine('&&', $expr));
165 165
 
166
-		$manager->deleteItems( array_keys( $manager->searchItems( $search ) ) );
166
+		$manager->deleteItems(array_keys($manager->searchItems($search)));
167 167
 	}
168 168
 }
Please login to merge, or discard this patch.