@@ -11,17 +11,17 @@ |
||
11 | 11 | * Set error reporting to maximum |
12 | 12 | */ |
13 | 13 | error_reporting( -1 ); |
14 | -ini_set( 'display_errors', '1' ); |
|
14 | +ini_set('display_errors', '1'); |
|
15 | 15 | |
16 | -date_default_timezone_set( 'UTC' ); |
|
16 | +date_default_timezone_set('UTC'); |
|
17 | 17 | |
18 | 18 | /* |
19 | 19 | * Set locale settings to reasonable defaults |
20 | 20 | */ |
21 | -setlocale( LC_ALL, 'en_US.UTF-8' ); |
|
22 | -setlocale( LC_NUMERIC, 'POSIX' ); |
|
23 | -setlocale( LC_CTYPE, 'en_US.UTF-8' ); |
|
24 | -setlocale( LC_TIME, 'POSIX' ); |
|
21 | +setlocale(LC_ALL, 'en_US.UTF-8'); |
|
22 | +setlocale(LC_NUMERIC, 'POSIX'); |
|
23 | +setlocale(LC_CTYPE, 'en_US.UTF-8'); |
|
24 | +setlocale(LC_TIME, 'POSIX'); |
|
25 | 25 | |
26 | 26 | |
27 | 27 | require_once 'TestHelperJqadm.php'; |
@@ -67,17 +67,17 @@ discard block |
||
67 | 67 | { |
68 | 68 | $view = $this->getView(); |
69 | 69 | |
70 | - $this->setData( $view ); |
|
70 | + $this->setData($view); |
|
71 | 71 | $view->attributeBody = ''; |
72 | 72 | |
73 | - foreach( $this->getSubClients() as $client ) { |
|
73 | + foreach ($this->getSubClients() as $client) { |
|
74 | 74 | $view->attributeBody .= $client->copy(); |
75 | 75 | } |
76 | 76 | |
77 | 77 | $tplconf = 'admin/jqadm/product/characteristic/attribute/template-item'; |
78 | 78 | $default = 'product/item-characteristic-attribute-default.php'; |
79 | 79 | |
80 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
80 | + return $view->render($view->config($tplconf, $default)); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -90,17 +90,17 @@ discard block |
||
90 | 90 | { |
91 | 91 | $view = $this->getView(); |
92 | 92 | |
93 | - $this->setData( $view ); |
|
93 | + $this->setData($view); |
|
94 | 94 | $view->attributeBody = ''; |
95 | 95 | |
96 | - foreach( $this->getSubClients() as $client ) { |
|
96 | + foreach ($this->getSubClients() as $client) { |
|
97 | 97 | $view->attributeBody .= $client->create(); |
98 | 98 | } |
99 | 99 | |
100 | 100 | $tplconf = 'admin/jqadm/product/characteristic/attribute/template-item'; |
101 | 101 | $default = 'product/item-characteristic-attribute-default.php'; |
102 | 102 | |
103 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
103 | + return $view->render($view->config($tplconf, $default)); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | |
@@ -113,17 +113,17 @@ discard block |
||
113 | 113 | { |
114 | 114 | $view = $this->getView(); |
115 | 115 | |
116 | - $this->setData( $view ); |
|
116 | + $this->setData($view); |
|
117 | 117 | $view->attributeBody = ''; |
118 | 118 | |
119 | - foreach( $this->getSubClients() as $client ) { |
|
119 | + foreach ($this->getSubClients() as $client) { |
|
120 | 120 | $view->attributeBody .= $client->get(); |
121 | 121 | } |
122 | 122 | |
123 | 123 | $tplconf = 'admin/jqadm/product/characteristic/attribute/template-item'; |
124 | 124 | $default = 'product/item-characteristic-attribute-default.php'; |
125 | 125 | |
126 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
126 | + return $view->render($view->config($tplconf, $default)); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
@@ -137,32 +137,32 @@ discard block |
||
137 | 137 | $view = $this->getView(); |
138 | 138 | $context = $this->getContext(); |
139 | 139 | |
140 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' ); |
|
140 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); |
|
141 | 141 | $manager->begin(); |
142 | 142 | |
143 | 143 | try |
144 | 144 | { |
145 | - $this->updateItems( $view ); |
|
145 | + $this->updateItems($view); |
|
146 | 146 | $view->attributeBody = ''; |
147 | 147 | |
148 | - foreach( $this->getSubClients() as $client ) { |
|
148 | + foreach ($this->getSubClients() as $client) { |
|
149 | 149 | $view->attributeBody .= $client->save(); |
150 | 150 | } |
151 | 151 | |
152 | 152 | $manager->commit(); |
153 | 153 | return; |
154 | 154 | } |
155 | - catch( \Aimeos\MShop\Exception $e ) |
|
155 | + catch (\Aimeos\MShop\Exception $e) |
|
156 | 156 | { |
157 | - $error = array( 'product-item-characteristic-attribute' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
|
158 | - $view->errors = $view->get( 'errors', array() ) + $error; |
|
157 | + $error = array('product-item-characteristic-attribute' => $context->getI18n()->dt('mshop', $e->getMessage())); |
|
158 | + $view->errors = $view->get('errors', array()) + $error; |
|
159 | 159 | $manager->rollback(); |
160 | 160 | } |
161 | - catch( \Exception $e ) |
|
161 | + catch (\Exception $e) |
|
162 | 162 | { |
163 | - $context->getLogger()->log( $e->getMessage() . ' - ' . $e->getTraceAsString() ); |
|
164 | - $error = array( 'product-item-characteristic-attribute' => $e->getMessage() ); |
|
165 | - $view->errors = $view->get( 'errors', array() ) + $error; |
|
163 | + $context->getLogger()->log($e->getMessage() . ' - ' . $e->getTraceAsString()); |
|
164 | + $error = array('product-item-characteristic-attribute' => $e->getMessage()); |
|
165 | + $view->errors = $view->get('errors', array()) + $error; |
|
166 | 166 | $manager->rollback(); |
167 | 167 | } |
168 | 168 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @param string|null $name Name of the sub-client (Default if null) |
178 | 178 | * @return \Aimeos\Admin\JQAdm\Iface Sub-client object |
179 | 179 | */ |
180 | - public function getSubClient( $type, $name = null ) |
|
180 | + public function getSubClient($type, $name = null) |
|
181 | 181 | { |
182 | 182 | /** admin/jqadm/product/characteristic/attribute/decorators/excludes |
183 | 183 | * Excludes decorators added by the "common" option from the product JQAdm client |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @see admin/jqadm/product/characteristic/attribute/decorators/excludes |
253 | 253 | * @see admin/jqadm/product/characteristic/attribute/decorators/global |
254 | 254 | */ |
255 | - return $this->createSubClient( 'product/characteristic/attribute/' . $type, $name ); |
|
255 | + return $this->createSubClient('product/characteristic/attribute/' . $type, $name); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | */ |
264 | 264 | protected function getSubClientNames() |
265 | 265 | { |
266 | - return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames ); |
|
266 | + return $this->getContext()->getConfig()->get($this->subPartPath, $this->subPartNames); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -273,20 +273,20 @@ discard block |
||
273 | 273 | * @param string $prodid Unique product ID |
274 | 274 | * @return array Associative list of attribute product IDs as keys and list items as values |
275 | 275 | */ |
276 | - protected function getListItems( $prodid ) |
|
276 | + protected function getListItems($prodid) |
|
277 | 277 | { |
278 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' ); |
|
278 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists'); |
|
279 | 279 | |
280 | 280 | $search = $manager->createSearch(); |
281 | 281 | $expr = array( |
282 | - $search->compare( '==', 'product.lists.parentid', $prodid ), |
|
283 | - $search->compare( '==', 'product.lists.domain', 'attribute' ), |
|
284 | - $search->compare( '==', 'product.lists.type.domain', 'attribute' ), |
|
285 | - $search->compare( '==', 'product.lists.type.code', 'default' ), |
|
282 | + $search->compare('==', 'product.lists.parentid', $prodid), |
|
283 | + $search->compare('==', 'product.lists.domain', 'attribute'), |
|
284 | + $search->compare('==', 'product.lists.type.domain', 'attribute'), |
|
285 | + $search->compare('==', 'product.lists.type.code', 'default'), |
|
286 | 286 | ); |
287 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
287 | + $search->setConditions($search->combine('&&', $expr)); |
|
288 | 288 | |
289 | - return $manager->searchItems( $search ); |
|
289 | + return $manager->searchItems($search); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | |
@@ -295,18 +295,18 @@ discard block |
||
295 | 295 | * |
296 | 296 | * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters |
297 | 297 | */ |
298 | - protected function setData( \Aimeos\MW\View\Iface $view ) |
|
298 | + protected function setData(\Aimeos\MW\View\Iface $view) |
|
299 | 299 | { |
300 | - $data = (array) $view->param( 'characteristic/attribute', array() ); |
|
300 | + $data = (array) $view->param('characteristic/attribute', array()); |
|
301 | 301 | |
302 | - if( empty( $data ) ) |
|
302 | + if (empty($data)) |
|
303 | 303 | { |
304 | - foreach( $view->item->getListItems( 'attribute', 'default' ) as $listItem ) |
|
304 | + foreach ($view->item->getListItems('attribute', 'default') as $listItem) |
|
305 | 305 | { |
306 | 306 | $refItem = $listItem->getRefItem(); |
307 | - $data['attribute.label'][] = ( $refItem ? $refItem->getLabel() : '' ); |
|
307 | + $data['attribute.label'][] = ($refItem ? $refItem->getLabel() : ''); |
|
308 | 308 | |
309 | - foreach( $listItem->toArray() as $key => $value ) { |
|
309 | + foreach ($listItem->toArray() as $key => $value) { |
|
310 | 310 | $data[$key][] = $value; |
311 | 311 | } |
312 | 312 | } |
@@ -321,39 +321,39 @@ discard block |
||
321 | 321 | * |
322 | 322 | * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters |
323 | 323 | */ |
324 | - protected function updateItems( \Aimeos\MW\View\Iface $view ) |
|
324 | + protected function updateItems(\Aimeos\MW\View\Iface $view) |
|
325 | 325 | { |
326 | 326 | $context = $this->getContext(); |
327 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' ); |
|
328 | - $typeManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists/type' ); |
|
327 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); |
|
328 | + $typeManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists/type'); |
|
329 | 329 | |
330 | 330 | $id = $view->item->getId(); |
331 | - $map = $this->getListItems( $id ); |
|
332 | - $listIds = (array) $view->param( 'characteristic/attribute/product.lists.id', array() ); |
|
331 | + $map = $this->getListItems($id); |
|
332 | + $listIds = (array) $view->param('characteristic/attribute/product.lists.id', array()); |
|
333 | 333 | |
334 | 334 | |
335 | - foreach( $listIds as $pos => $listid ) |
|
335 | + foreach ($listIds as $pos => $listid) |
|
336 | 336 | { |
337 | - if( isset( $map[$listid] ) ) { |
|
338 | - unset( $map[$listid], $listIds[$pos] ); |
|
337 | + if (isset($map[$listid])) { |
|
338 | + unset($map[$listid], $listIds[$pos]); |
|
339 | 339 | } |
340 | 340 | } |
341 | 341 | |
342 | - $manager->deleteItems( array_keys( $map ) ); |
|
342 | + $manager->deleteItems(array_keys($map)); |
|
343 | 343 | |
344 | 344 | |
345 | 345 | $item = $manager->createItem(); |
346 | - $item->setTypeId( $typeManager->findItem( 'default', array(), 'attribute' )->getId() ); |
|
347 | - $item->setDomain( 'attribute' ); |
|
348 | - $item->setParentId( $id ); |
|
346 | + $item->setTypeId($typeManager->findItem('default', array(), 'attribute')->getId()); |
|
347 | + $item->setDomain('attribute'); |
|
348 | + $item->setParentId($id); |
|
349 | 349 | |
350 | - foreach( $listIds as $pos => $listid ) |
|
350 | + foreach ($listIds as $pos => $listid) |
|
351 | 351 | { |
352 | - $item->setId( null ); |
|
353 | - $item->setRefId( $view->param( 'characteristic/attribute/product.lists.refid/' . $pos ) ); |
|
354 | - $item->setPosition( $pos ); |
|
352 | + $item->setId(null); |
|
353 | + $item->setRefId($view->param('characteristic/attribute/product.lists.refid/' . $pos)); |
|
354 | + $item->setPosition($pos); |
|
355 | 355 | |
356 | - $manager->saveItem( $item, false ); |
|
356 | + $manager->saveItem($item, false); |
|
357 | 357 | } |
358 | 358 | } |
359 | 359 | } |
360 | 360 | \ No newline at end of file |
@@ -151,14 +151,12 @@ |
||
151 | 151 | |
152 | 152 | $manager->commit(); |
153 | 153 | return; |
154 | - } |
|
155 | - catch( \Aimeos\MShop\Exception $e ) |
|
154 | + } catch( \Aimeos\MShop\Exception $e ) |
|
156 | 155 | { |
157 | 156 | $error = array( 'product-item-category' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
158 | 157 | $view->errors = $view->get( 'errors', array() ) + $error; |
159 | 158 | $manager->rollback(); |
160 | - } |
|
161 | - catch( \Exception $e ) |
|
159 | + } catch( \Exception $e ) |
|
162 | 160 | { |
163 | 161 | $context->getLogger()->log( $e->getMessage() . ' - ' . $e->getTraceAsString() ); |
164 | 162 | $error = array( 'product-item-category' => $e->getMessage() ); |
@@ -67,17 +67,17 @@ discard block |
||
67 | 67 | { |
68 | 68 | $view = $this->getView(); |
69 | 69 | |
70 | - $this->setData( $view ); |
|
70 | + $this->setData($view); |
|
71 | 71 | $view->propertyBody = ''; |
72 | 72 | |
73 | - foreach( $this->getSubClients() as $client ) { |
|
73 | + foreach ($this->getSubClients() as $client) { |
|
74 | 74 | $view->propertyBody .= $client->copy(); |
75 | 75 | } |
76 | 76 | |
77 | 77 | $tplconf = 'admin/jqadm/product/characteristic/property/template-item'; |
78 | 78 | $default = 'product/item-characteristic-property-default.php'; |
79 | 79 | |
80 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
80 | + return $view->render($view->config($tplconf, $default)); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -90,17 +90,17 @@ discard block |
||
90 | 90 | { |
91 | 91 | $view = $this->getView(); |
92 | 92 | |
93 | - $this->setData( $view ); |
|
93 | + $this->setData($view); |
|
94 | 94 | $view->propertyBody = ''; |
95 | 95 | |
96 | - foreach( $this->getSubClients() as $client ) { |
|
96 | + foreach ($this->getSubClients() as $client) { |
|
97 | 97 | $view->propertyBody .= $client->create(); |
98 | 98 | } |
99 | 99 | |
100 | 100 | $tplconf = 'admin/jqadm/product/characteristic/property/template-item'; |
101 | 101 | $default = 'product/item-characteristic-property-default.php'; |
102 | 102 | |
103 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
103 | + return $view->render($view->config($tplconf, $default)); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | |
@@ -113,17 +113,17 @@ discard block |
||
113 | 113 | { |
114 | 114 | $view = $this->getView(); |
115 | 115 | |
116 | - $this->setData( $view ); |
|
116 | + $this->setData($view); |
|
117 | 117 | $view->propertyBody = ''; |
118 | 118 | |
119 | - foreach( $this->getSubClients() as $client ) { |
|
119 | + foreach ($this->getSubClients() as $client) { |
|
120 | 120 | $view->propertyBody .= $client->get(); |
121 | 121 | } |
122 | 122 | |
123 | 123 | $tplconf = 'admin/jqadm/product/characteristic/property/template-item'; |
124 | 124 | $default = 'product/item-characteristic-property-default.php'; |
125 | 125 | |
126 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
126 | + return $view->render($view->config($tplconf, $default)); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
@@ -137,32 +137,32 @@ discard block |
||
137 | 137 | $view = $this->getView(); |
138 | 138 | $context = $this->getContext(); |
139 | 139 | |
140 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' ); |
|
140 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); |
|
141 | 141 | $manager->begin(); |
142 | 142 | |
143 | 143 | try |
144 | 144 | { |
145 | - $this->updateItems( $view ); |
|
145 | + $this->updateItems($view); |
|
146 | 146 | $view->propertyBody = ''; |
147 | 147 | |
148 | - foreach( $this->getSubClients() as $client ) { |
|
148 | + foreach ($this->getSubClients() as $client) { |
|
149 | 149 | $view->propertyBody .= $client->save(); |
150 | 150 | } |
151 | 151 | |
152 | 152 | $manager->commit(); |
153 | 153 | return; |
154 | 154 | } |
155 | - catch( \Aimeos\MShop\Exception $e ) |
|
155 | + catch (\Aimeos\MShop\Exception $e) |
|
156 | 156 | { |
157 | - $error = array( 'product-item-characteristic-property' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
|
158 | - $view->errors = $view->get( 'errors', array() ) + $error; |
|
157 | + $error = array('product-item-characteristic-property' => $context->getI18n()->dt('mshop', $e->getMessage())); |
|
158 | + $view->errors = $view->get('errors', array()) + $error; |
|
159 | 159 | $manager->rollback(); |
160 | 160 | } |
161 | - catch( \Exception $e ) |
|
161 | + catch (\Exception $e) |
|
162 | 162 | { |
163 | - $context->getLogger()->log( $e->getMessage() . ' - ' . $e->getTraceAsString() ); |
|
164 | - $error = array( 'product-item-characteristic-property' => $e->getMessage() ); |
|
165 | - $view->errors = $view->get( 'errors', array() ) + $error; |
|
163 | + $context->getLogger()->log($e->getMessage() . ' - ' . $e->getTraceAsString()); |
|
164 | + $error = array('product-item-characteristic-property' => $e->getMessage()); |
|
165 | + $view->errors = $view->get('errors', array()) + $error; |
|
166 | 166 | $manager->rollback(); |
167 | 167 | } |
168 | 168 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @param string|null $name Name of the sub-client (Default if null) |
178 | 178 | * @return \Aimeos\Admin\JQAdm\Iface Sub-client object |
179 | 179 | */ |
180 | - public function getSubClient( $type, $name = null ) |
|
180 | + public function getSubClient($type, $name = null) |
|
181 | 181 | { |
182 | 182 | /** admin/jqadm/product/characteristic/property/decorators/excludes |
183 | 183 | * Excludes decorators added by the "common" option from the product JQAdm client |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @see admin/jqadm/product/characteristic/property/decorators/excludes |
253 | 253 | * @see admin/jqadm/product/characteristic/property/decorators/global |
254 | 254 | */ |
255 | - return $this->createSubClient( 'product/characteristic/property/' . $type, $name ); |
|
255 | + return $this->createSubClient('product/characteristic/property/' . $type, $name); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | */ |
264 | 264 | protected function getSubClientNames() |
265 | 265 | { |
266 | - return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames ); |
|
266 | + return $this->getContext()->getConfig()->get($this->subPartPath, $this->subPartNames); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -273,20 +273,20 @@ discard block |
||
273 | 273 | * @param string $prodid Unique product ID |
274 | 274 | * @return array Associative list of property IDs as keys and property items as values |
275 | 275 | */ |
276 | - protected function getProperties( $prodid ) |
|
276 | + protected function getProperties($prodid) |
|
277 | 277 | { |
278 | - $excludes = array( 'package-length', 'package-height', 'package-width', 'package-weight' ); |
|
279 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/property' ); |
|
278 | + $excludes = array('package-length', 'package-height', 'package-width', 'package-weight'); |
|
279 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/property'); |
|
280 | 280 | |
281 | 281 | $search = $manager->createSearch(); |
282 | 282 | $expr = array( |
283 | - $search->compare( '==', 'product.property.parentid', $prodid ), |
|
284 | - $search->compare( '!=', 'product.property.type.code', $excludes ), |
|
283 | + $search->compare('==', 'product.property.parentid', $prodid), |
|
284 | + $search->compare('!=', 'product.property.type.code', $excludes), |
|
285 | 285 | ); |
286 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
287 | - $search->setSlice( 0, 0x7fffffff ); |
|
286 | + $search->setConditions($search->combine('&&', $expr)); |
|
287 | + $search->setSlice(0, 0x7fffffff); |
|
288 | 288 | |
289 | - return $manager->searchItems( $search ); |
|
289 | + return $manager->searchItems($search); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | |
@@ -297,14 +297,14 @@ discard block |
||
297 | 297 | */ |
298 | 298 | protected function getPropertyTypes() |
299 | 299 | { |
300 | - $excludes = array( 'package-length', 'package-height', 'package-width', 'package-weight' ); |
|
301 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/property/type' ); |
|
300 | + $excludes = array('package-length', 'package-height', 'package-width', 'package-weight'); |
|
301 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/property/type'); |
|
302 | 302 | |
303 | 303 | $search = $manager->createSearch(); |
304 | - $search->setConditions( $search->compare( '!=', 'product.property.type.code', $excludes ) ); |
|
305 | - $search->setSlice( 0, 0x7fffffff ); |
|
304 | + $search->setConditions($search->compare('!=', 'product.property.type.code', $excludes)); |
|
305 | + $search->setSlice(0, 0x7fffffff); |
|
306 | 306 | |
307 | - return $manager->searchItems( $search ); |
|
307 | + return $manager->searchItems($search); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | |
@@ -313,15 +313,15 @@ discard block |
||
313 | 313 | * |
314 | 314 | * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters |
315 | 315 | */ |
316 | - protected function setData( \Aimeos\MW\View\Iface $view ) |
|
316 | + protected function setData(\Aimeos\MW\View\Iface $view) |
|
317 | 317 | { |
318 | - $data = (array) $view->param( 'characteristic/property', array() ); |
|
318 | + $data = (array) $view->param('characteristic/property', array()); |
|
319 | 319 | |
320 | - if( empty( $data ) ) |
|
320 | + if (empty($data)) |
|
321 | 321 | { |
322 | - foreach( $this->getProperties( $view->item->getId() ) as $item ) |
|
322 | + foreach ($this->getProperties($view->item->getId()) as $item) |
|
323 | 323 | { |
324 | - foreach( $item->toArray() as $key => $value ) { |
|
324 | + foreach ($item->toArray() as $key => $value) { |
|
325 | 325 | $data[$key][] = $value; |
326 | 326 | } |
327 | 327 | } |
@@ -337,38 +337,38 @@ discard block |
||
337 | 337 | * |
338 | 338 | * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters |
339 | 339 | */ |
340 | - protected function updateItems( \Aimeos\MW\View\Iface $view ) |
|
340 | + protected function updateItems(\Aimeos\MW\View\Iface $view) |
|
341 | 341 | { |
342 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/property' ); |
|
342 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/property'); |
|
343 | 343 | |
344 | 344 | $id = $view->item->getId(); |
345 | - $map = $this->getProperties( $id ); |
|
346 | - $ids = (array) $view->param( 'characteristic/property/product.property.id', array() ); |
|
345 | + $map = $this->getProperties($id); |
|
346 | + $ids = (array) $view->param('characteristic/property/product.property.id', array()); |
|
347 | 347 | |
348 | 348 | $item = $manager->createItem(); |
349 | 349 | |
350 | - foreach( $ids as $pos => $propertyId ) |
|
350 | + foreach ($ids as $pos => $propertyId) |
|
351 | 351 | { |
352 | - if( isset( $map[$propertyId] ) ) |
|
352 | + if (isset($map[$propertyId])) |
|
353 | 353 | { |
354 | 354 | $item = $map[$propertyId]; |
355 | - unset( $map[$propertyId] ); |
|
355 | + unset($map[$propertyId]); |
|
356 | 356 | } |
357 | 357 | else |
358 | 358 | { |
359 | - $item->setId( null ); |
|
360 | - $item->setParentId( $id ); |
|
359 | + $item->setId(null); |
|
360 | + $item->setParentId($id); |
|
361 | 361 | } |
362 | 362 | |
363 | - $lang = $view->param( 'characteristic/property/product.property.languageid/' . $pos, null ); |
|
363 | + $lang = $view->param('characteristic/property/product.property.languageid/' . $pos, null); |
|
364 | 364 | |
365 | - $item->setLanguageId( ( $lang ? $lang : null ) ); |
|
366 | - $item->setTypeId( $view->param( 'characteristic/property/product.property.typeid/' . $pos, null ) ); |
|
367 | - $item->setValue( $view->param( 'characteristic/property/product.property.value/' . $pos, '' ) ); |
|
365 | + $item->setLanguageId(($lang ? $lang : null)); |
|
366 | + $item->setTypeId($view->param('characteristic/property/product.property.typeid/' . $pos, null)); |
|
367 | + $item->setValue($view->param('characteristic/property/product.property.value/' . $pos, '')); |
|
368 | 368 | |
369 | - $manager->saveItem( $item, false ); |
|
369 | + $manager->saveItem($item, false); |
|
370 | 370 | } |
371 | 371 | |
372 | - $manager->deleteItems( array_keys( $map ) ); |
|
372 | + $manager->deleteItems(array_keys($map)); |
|
373 | 373 | } |
374 | 374 | } |
@@ -155,16 +155,14 @@ discard block |
||
155 | 155 | $textManager->commit(); |
156 | 156 | $manager->commit(); |
157 | 157 | return; |
158 | - } |
|
159 | - catch( \Aimeos\MShop\Exception $e ) |
|
158 | + } catch( \Aimeos\MShop\Exception $e ) |
|
160 | 159 | { |
161 | 160 | $error = array( 'product-item-price' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
162 | 161 | $view->errors = $view->get( 'errors', array() ) + $error; |
163 | 162 | |
164 | 163 | $textManager->rollback(); |
165 | 164 | $manager->rollback(); |
166 | - } |
|
167 | - catch( \Exception $e ) |
|
165 | + } catch( \Exception $e ) |
|
168 | 166 | { |
169 | 167 | $context->getLogger()->log( $e->getMessage() . ' - ' . $e->getTraceAsString() ); |
170 | 168 | $error = array( 'product-item-price' => $e->getMessage() ); |
@@ -365,8 +363,7 @@ discard block |
||
365 | 363 | |
366 | 364 | $item = $priceItem; |
367 | 365 | $item->setId( null ); |
368 | - } |
|
369 | - else |
|
366 | + } else |
|
370 | 367 | { |
371 | 368 | $litem = $listItems[$listid]; |
372 | 369 | $item = $litem->getRefItem(); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @category Developer |
56 | 56 | */ |
57 | 57 | private $subPartPath = 'admin/jqadm/product/characteristic/standard/subparts'; |
58 | - private $subPartNames = array( 'attribute', 'property' ); |
|
58 | + private $subPartNames = array('attribute', 'property'); |
|
59 | 59 | |
60 | 60 | |
61 | 61 | /** |
@@ -67,17 +67,17 @@ discard block |
||
67 | 67 | { |
68 | 68 | $view = $this->getView(); |
69 | 69 | |
70 | - $this->setData( $view ); |
|
70 | + $this->setData($view); |
|
71 | 71 | $view->characteristicBody = ''; |
72 | 72 | |
73 | - foreach( $this->getSubClients() as $client ) { |
|
73 | + foreach ($this->getSubClients() as $client) { |
|
74 | 74 | $view->characteristicBody .= $client->copy(); |
75 | 75 | } |
76 | 76 | |
77 | 77 | $tplconf = 'admin/jqadm/product/characteristic/template-item'; |
78 | 78 | $default = 'product/item-characteristic-default.php'; |
79 | 79 | |
80 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
80 | + return $view->render($view->config($tplconf, $default)); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -90,17 +90,17 @@ discard block |
||
90 | 90 | { |
91 | 91 | $view = $this->getView(); |
92 | 92 | |
93 | - $this->setData( $view ); |
|
93 | + $this->setData($view); |
|
94 | 94 | $view->characteristicBody = ''; |
95 | 95 | |
96 | - foreach( $this->getSubClients() as $client ) { |
|
96 | + foreach ($this->getSubClients() as $client) { |
|
97 | 97 | $view->characteristicBody .= $client->create(); |
98 | 98 | } |
99 | 99 | |
100 | 100 | $tplconf = 'admin/jqadm/product/characteristic/template-item'; |
101 | 101 | $default = 'product/item-characteristic-default.php'; |
102 | 102 | |
103 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
103 | + return $view->render($view->config($tplconf, $default)); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | |
@@ -113,17 +113,17 @@ discard block |
||
113 | 113 | { |
114 | 114 | $view = $this->getView(); |
115 | 115 | |
116 | - $this->setData( $view ); |
|
116 | + $this->setData($view); |
|
117 | 117 | $view->characteristicBody = ''; |
118 | 118 | |
119 | - foreach( $this->getSubClients() as $client ) { |
|
119 | + foreach ($this->getSubClients() as $client) { |
|
120 | 120 | $view->characteristicBody .= $client->get(); |
121 | 121 | } |
122 | 122 | |
123 | 123 | $tplconf = 'admin/jqadm/product/characteristic/template-item'; |
124 | 124 | $default = 'product/item-characteristic-default.php'; |
125 | 125 | |
126 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
126 | + return $view->render($view->config($tplconf, $default)); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
@@ -137,31 +137,31 @@ discard block |
||
137 | 137 | $view = $this->getView(); |
138 | 138 | $context = $this->getContext(); |
139 | 139 | |
140 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' ); |
|
140 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); |
|
141 | 141 | $manager->begin(); |
142 | 142 | |
143 | 143 | try |
144 | 144 | { |
145 | 145 | $view->characteristicBody = ''; |
146 | 146 | |
147 | - foreach( $this->getSubClients() as $client ) { |
|
147 | + foreach ($this->getSubClients() as $client) { |
|
148 | 148 | $view->characteristicBody .= $client->save(); |
149 | 149 | } |
150 | 150 | |
151 | 151 | $manager->commit(); |
152 | 152 | return; |
153 | 153 | } |
154 | - catch( \Aimeos\MShop\Exception $e ) |
|
154 | + catch (\Aimeos\MShop\Exception $e) |
|
155 | 155 | { |
156 | - $error = array( 'product-item-characteristic' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
|
157 | - $view->errors = $view->get( 'errors', array() ) + $error; |
|
156 | + $error = array('product-item-characteristic' => $context->getI18n()->dt('mshop', $e->getMessage())); |
|
157 | + $view->errors = $view->get('errors', array()) + $error; |
|
158 | 158 | $manager->rollback(); |
159 | 159 | } |
160 | - catch( \Exception $e ) |
|
160 | + catch (\Exception $e) |
|
161 | 161 | { |
162 | - $context->getLogger()->log( $e->getMessage() . ' - ' . $e->getTraceAsString() ); |
|
163 | - $error = array( 'product-item-characteristic' => $e->getMessage() ); |
|
164 | - $view->errors = $view->get( 'errors', array() ) + $error; |
|
162 | + $context->getLogger()->log($e->getMessage() . ' - ' . $e->getTraceAsString()); |
|
163 | + $error = array('product-item-characteristic' => $e->getMessage()); |
|
164 | + $view->errors = $view->get('errors', array()) + $error; |
|
165 | 165 | $manager->rollback(); |
166 | 166 | } |
167 | 167 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @param string|null $name Name of the sub-client (Default if null) |
177 | 177 | * @return \Aimeos\Admin\JQAdm\Iface Sub-client object |
178 | 178 | */ |
179 | - public function getSubClient( $type, $name = null ) |
|
179 | + public function getSubClient($type, $name = null) |
|
180 | 180 | { |
181 | 181 | /** admin/jqadm/product/characteristic/decorators/excludes |
182 | 182 | * Excludes decorators added by the "common" option from the product JQAdm client |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @see admin/jqadm/product/characteristic/decorators/excludes |
252 | 252 | * @see admin/jqadm/product/characteristic/decorators/global |
253 | 253 | */ |
254 | - return $this->createSubClient( 'product/characteristic/' . $type, $name ); |
|
254 | + return $this->createSubClient('product/characteristic/' . $type, $name); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | */ |
263 | 263 | protected function getSubClientNames() |
264 | 264 | { |
265 | - return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames ); |
|
265 | + return $this->getContext()->getConfig()->get($this->subPartPath, $this->subPartNames); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | |
@@ -271,8 +271,8 @@ discard block |
||
271 | 271 | * |
272 | 272 | * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters |
273 | 273 | */ |
274 | - protected function setData( \Aimeos\MW\View\Iface $view ) |
|
274 | + protected function setData(\Aimeos\MW\View\Iface $view) |
|
275 | 275 | { |
276 | - $view->characteristicData = (array) $view->param( 'characteristic', array() );; |
|
276 | + $view->characteristicData = (array) $view->param('characteristic', array()); ; |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | \ No newline at end of file |
@@ -151,14 +151,12 @@ |
||
151 | 151 | |
152 | 152 | $manager->commit(); |
153 | 153 | return; |
154 | - } |
|
155 | - catch( \Aimeos\MShop\Exception $e ) |
|
154 | + } catch( \Aimeos\MShop\Exception $e ) |
|
156 | 155 | { |
157 | 156 | $error = array( 'product-item-category' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
158 | 157 | $view->errors = $view->get( 'errors', array() ) + $error; |
159 | 158 | $manager->rollback(); |
160 | - } |
|
161 | - catch( \Exception $e ) |
|
159 | + } catch( \Exception $e ) |
|
162 | 160 | { |
163 | 161 | $context->getLogger()->log( $e->getMessage() . ' - ' . $e->getTraceAsString() ); |
164 | 162 | $error = array( 'product-item-category' => $e->getMessage() ); |
@@ -67,17 +67,17 @@ discard block |
||
67 | 67 | { |
68 | 68 | $view = $this->getView(); |
69 | 69 | |
70 | - $this->setData( $view ); |
|
70 | + $this->setData($view); |
|
71 | 71 | $view->priceBody = ''; |
72 | 72 | |
73 | - foreach( $this->getSubClients() as $client ) { |
|
73 | + foreach ($this->getSubClients() as $client) { |
|
74 | 74 | $view->priceBody .= $client->copy(); |
75 | 75 | } |
76 | 76 | |
77 | 77 | $tplconf = 'admin/jqadm/product/price/template-item'; |
78 | 78 | $default = 'product/item-price-default.php'; |
79 | 79 | |
80 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
80 | + return $view->render($view->config($tplconf, $default)); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -90,17 +90,17 @@ discard block |
||
90 | 90 | { |
91 | 91 | $view = $this->getView(); |
92 | 92 | |
93 | - $this->setData( $view ); |
|
93 | + $this->setData($view); |
|
94 | 94 | $view->priceBody = ''; |
95 | 95 | |
96 | - foreach( $this->getSubClients() as $client ) { |
|
96 | + foreach ($this->getSubClients() as $client) { |
|
97 | 97 | $view->priceBody .= $client->create(); |
98 | 98 | } |
99 | 99 | |
100 | 100 | $tplconf = 'admin/jqadm/product/price/template-item'; |
101 | 101 | $default = 'product/item-price-default.php'; |
102 | 102 | |
103 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
103 | + return $view->render($view->config($tplconf, $default)); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | |
@@ -113,17 +113,17 @@ discard block |
||
113 | 113 | { |
114 | 114 | $view = $this->getView(); |
115 | 115 | |
116 | - $this->setData( $view ); |
|
116 | + $this->setData($view); |
|
117 | 117 | $view->priceBody = ''; |
118 | 118 | |
119 | - foreach( $this->getSubClients() as $client ) { |
|
119 | + foreach ($this->getSubClients() as $client) { |
|
120 | 120 | $view->priceBody .= $client->get(); |
121 | 121 | } |
122 | 122 | |
123 | 123 | $tplconf = 'admin/jqadm/product/price/template-item'; |
124 | 124 | $default = 'product/item-price-default.php'; |
125 | 125 | |
126 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
126 | + return $view->render($view->config($tplconf, $default)); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
@@ -137,18 +137,18 @@ discard block |
||
137 | 137 | $view = $this->getView(); |
138 | 138 | $context = $this->getContext(); |
139 | 139 | |
140 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' ); |
|
141 | - $textManager = \Aimeos\MShop\Factory::createManager( $context, 'text' ); |
|
140 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); |
|
141 | + $textManager = \Aimeos\MShop\Factory::createManager($context, 'text'); |
|
142 | 142 | |
143 | 143 | $manager->begin(); |
144 | 144 | $textManager->begin(); |
145 | 145 | |
146 | 146 | try |
147 | 147 | { |
148 | - $this->updateItems( $view ); |
|
148 | + $this->updateItems($view); |
|
149 | 149 | $view->priceBody = ''; |
150 | 150 | |
151 | - foreach( $this->getSubClients() as $client ) { |
|
151 | + foreach ($this->getSubClients() as $client) { |
|
152 | 152 | $view->priceBody .= $client->save(); |
153 | 153 | } |
154 | 154 | |
@@ -156,19 +156,19 @@ discard block |
||
156 | 156 | $manager->commit(); |
157 | 157 | return; |
158 | 158 | } |
159 | - catch( \Aimeos\MShop\Exception $e ) |
|
159 | + catch (\Aimeos\MShop\Exception $e) |
|
160 | 160 | { |
161 | - $error = array( 'product-item-price' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
|
162 | - $view->errors = $view->get( 'errors', array() ) + $error; |
|
161 | + $error = array('product-item-price' => $context->getI18n()->dt('mshop', $e->getMessage())); |
|
162 | + $view->errors = $view->get('errors', array()) + $error; |
|
163 | 163 | |
164 | 164 | $textManager->rollback(); |
165 | 165 | $manager->rollback(); |
166 | 166 | } |
167 | - catch( \Exception $e ) |
|
167 | + catch (\Exception $e) |
|
168 | 168 | { |
169 | - $context->getLogger()->log( $e->getMessage() . ' - ' . $e->getTraceAsString() ); |
|
170 | - $error = array( 'product-item-price' => $e->getMessage() ); |
|
171 | - $view->errors = $view->get( 'errors', array() ) + $error; |
|
169 | + $context->getLogger()->log($e->getMessage() . ' - ' . $e->getTraceAsString()); |
|
170 | + $error = array('product-item-price' => $e->getMessage()); |
|
171 | + $view->errors = $view->get('errors', array()) + $error; |
|
172 | 172 | |
173 | 173 | $textManager->rollback(); |
174 | 174 | $manager->rollback(); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * @param string|null $name Name of the sub-client (Default if null) |
186 | 186 | * @return \Aimeos\Admin\JQAdm\Iface Sub-client object |
187 | 187 | */ |
188 | - public function getSubClient( $type, $name = null ) |
|
188 | + public function getSubClient($type, $name = null) |
|
189 | 189 | { |
190 | 190 | /** admin/jqadm/product/price/decorators/excludes |
191 | 191 | * Excludes decorators added by the "common" option from the product JQAdm client |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @see admin/jqadm/product/price/decorators/excludes |
261 | 261 | * @see admin/jqadm/product/price/decorators/global |
262 | 262 | */ |
263 | - return $this->createSubClient( 'product/price/' . $type, $name ); |
|
263 | + return $this->createSubClient('product/price/' . $type, $name); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | */ |
272 | 272 | protected function getSubClientNames() |
273 | 273 | { |
274 | - return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames ); |
|
274 | + return $this->getContext()->getConfig()->get($this->subPartPath, $this->subPartNames); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | |
@@ -282,13 +282,13 @@ discard block |
||
282 | 282 | */ |
283 | 283 | protected function getPriceTypes() |
284 | 284 | { |
285 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'price/type' ); |
|
285 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'price/type'); |
|
286 | 286 | |
287 | 287 | $search = $manager->createSearch(); |
288 | - $search->setConditions( $search->compare( '==', 'price.type.domain', 'product' ) ); |
|
289 | - $search->setSortations( array( $search->sort( '+', 'price.type.label' ) ) ); |
|
288 | + $search->setConditions($search->compare('==', 'price.type.domain', 'product')); |
|
289 | + $search->setSortations(array($search->sort('+', 'price.type.label'))); |
|
290 | 290 | |
291 | - return $manager->searchItems( $search ); |
|
291 | + return $manager->searchItems($search); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | |
@@ -297,27 +297,27 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters |
299 | 299 | */ |
300 | - protected function setData( \Aimeos\MW\View\Iface $view ) |
|
300 | + protected function setData(\Aimeos\MW\View\Iface $view) |
|
301 | 301 | { |
302 | - $data = (array) $view->param( 'price', array() ); |
|
302 | + $data = (array) $view->param('price', array()); |
|
303 | 303 | |
304 | - if( empty( $view->priceData ) && ( $id = $view->item->getId() ) !== null ) |
|
304 | + if (empty($view->priceData) && ($id = $view->item->getId()) !== null) |
|
305 | 305 | { |
306 | - foreach( $view->item->getListItems( 'price' ) as $id => $listItem ) |
|
306 | + foreach ($view->item->getListItems('price') as $id => $listItem) |
|
307 | 307 | { |
308 | - if( ( $refItem = $listItem->getRefItem() ) === null ) { |
|
308 | + if (($refItem = $listItem->getRefItem()) === null) { |
|
309 | 309 | continue; |
310 | 310 | } |
311 | 311 | |
312 | 312 | $data['product.lists.id'][] = $id; |
313 | 313 | |
314 | - foreach( $refItem->toArray() as $key => $value ) { |
|
314 | + foreach ($refItem->toArray() as $key => $value) { |
|
315 | 315 | $data[$key][] = $value; |
316 | 316 | } |
317 | 317 | } |
318 | 318 | } |
319 | 319 | |
320 | - if( !isset( $data['price.currencyid'] ) ) { // show at least one block |
|
320 | + if (!isset($data['price.currencyid'])) { // show at least one block |
|
321 | 321 | $data['price.currencyid'][] = $this->getContext()->getLocale()->getCurrencyId(); |
322 | 322 | } |
323 | 323 | |
@@ -331,40 +331,40 @@ discard block |
||
331 | 331 | * |
332 | 332 | * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters |
333 | 333 | */ |
334 | - protected function updateItems( \Aimeos\MW\View\Iface $view ) |
|
334 | + protected function updateItems(\Aimeos\MW\View\Iface $view) |
|
335 | 335 | { |
336 | 336 | $id = $view->item->getId(); |
337 | 337 | $context = $this->getContext(); |
338 | 338 | |
339 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
340 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
341 | - $listManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' ); |
|
342 | - $listTypeManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists/type' ); |
|
339 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
340 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
341 | + $listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); |
|
342 | + $listTypeManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists/type'); |
|
343 | 343 | |
344 | - $listIds = (array) $view->param( 'price/product.lists.id', array() ); |
|
345 | - $listItems = $manager->getItem( $id, array( 'price' ) )->getListItems( 'price' ); |
|
344 | + $listIds = (array) $view->param('price/product.lists.id', array()); |
|
345 | + $listItems = $manager->getItem($id, array('price'))->getListItems('price'); |
|
346 | 346 | |
347 | 347 | |
348 | 348 | $listItem = $listManager->createItem(); |
349 | - $listItem->setTypeId( $listTypeManager->findItem( 'default', array(), 'price' )->getId() ); |
|
350 | - $listItem->setDomain( 'price' ); |
|
351 | - $listItem->setParentId( $id ); |
|
352 | - $listItem->setStatus( 1 ); |
|
349 | + $listItem->setTypeId($listTypeManager->findItem('default', array(), 'price')->getId()); |
|
350 | + $listItem->setDomain('price'); |
|
351 | + $listItem->setParentId($id); |
|
352 | + $listItem->setStatus(1); |
|
353 | 353 | |
354 | 354 | $priceItem = $priceManager->createItem(); |
355 | - $priceItem->setDomain( 'product' ); |
|
356 | - $priceItem->setStatus( 1 ); |
|
355 | + $priceItem->setDomain('product'); |
|
356 | + $priceItem->setStatus(1); |
|
357 | 357 | |
358 | 358 | |
359 | - foreach( $listIds as $idx => $listid ) |
|
359 | + foreach ($listIds as $idx => $listid) |
|
360 | 360 | { |
361 | - if( !isset( $listItems[$listid] ) ) |
|
361 | + if (!isset($listItems[$listid])) |
|
362 | 362 | { |
363 | 363 | $litem = $listItem; |
364 | - $litem->setId( null ); |
|
364 | + $litem->setId(null); |
|
365 | 365 | |
366 | 366 | $item = $priceItem; |
367 | - $item->setId( null ); |
|
367 | + $item->setId(null); |
|
368 | 368 | } |
369 | 369 | else |
370 | 370 | { |
@@ -372,32 +372,32 @@ discard block |
||
372 | 372 | $item = $litem->getRefItem(); |
373 | 373 | } |
374 | 374 | |
375 | - $item->setLabel( $view->param( 'price/price.label/' . $idx ) ); |
|
376 | - $item->setTypeId( $view->param( 'price/price.typeid/' . $idx ) ); |
|
377 | - $item->setCurrencyId( $view->param( 'price/price.currencyid/' . $idx ) ); |
|
378 | - $item->setQuantity( $view->param( 'price/price.quantity/' . $idx ) ); |
|
379 | - $item->setValue( $view->param( 'price/price.value/' . $idx ) ); |
|
380 | - $item->setCosts( $view->param( 'price/price.costs/' . $idx ) ); |
|
381 | - $item->setRebate( $view->param( 'price/price.rebate/' . $idx ) ); |
|
382 | - $item->setTaxRate( $view->param( 'price/price.taxrate/' . $idx ) ); |
|
375 | + $item->setLabel($view->param('price/price.label/' . $idx)); |
|
376 | + $item->setTypeId($view->param('price/price.typeid/' . $idx)); |
|
377 | + $item->setCurrencyId($view->param('price/price.currencyid/' . $idx)); |
|
378 | + $item->setQuantity($view->param('price/price.quantity/' . $idx)); |
|
379 | + $item->setValue($view->param('price/price.value/' . $idx)); |
|
380 | + $item->setCosts($view->param('price/price.costs/' . $idx)); |
|
381 | + $item->setRebate($view->param('price/price.rebate/' . $idx)); |
|
382 | + $item->setTaxRate($view->param('price/price.taxrate/' . $idx)); |
|
383 | 383 | |
384 | - $priceManager->saveItem( $item ); |
|
384 | + $priceManager->saveItem($item); |
|
385 | 385 | |
386 | - $litem->setPosition( $idx ); |
|
387 | - $litem->setRefId( $item->getId() ); |
|
386 | + $litem->setPosition($idx); |
|
387 | + $litem->setRefId($item->getId()); |
|
388 | 388 | |
389 | - $listManager->saveItem( $litem, false ); |
|
389 | + $listManager->saveItem($litem, false); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | |
393 | 393 | $rmIds = array(); |
394 | - $rmListIds = array_diff( array_keys( $listItems ), $listIds ); |
|
394 | + $rmListIds = array_diff(array_keys($listItems), $listIds); |
|
395 | 395 | |
396 | - foreach( $rmListIds as $id ) { |
|
396 | + foreach ($rmListIds as $id) { |
|
397 | 397 | $rmIds[] = $listItems[$id]->getRefId(); |
398 | 398 | } |
399 | 399 | |
400 | - $listManager->deleteItems( $rmListIds ); |
|
401 | - $priceManager->deleteItems( $rmIds ); |
|
400 | + $listManager->deleteItems($rmListIds); |
|
401 | + $priceManager->deleteItems($rmIds); |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 | \ No newline at end of file |
@@ -155,16 +155,14 @@ discard block |
||
155 | 155 | $textManager->commit(); |
156 | 156 | $manager->commit(); |
157 | 157 | return; |
158 | - } |
|
159 | - catch( \Aimeos\MShop\Exception $e ) |
|
158 | + } catch( \Aimeos\MShop\Exception $e ) |
|
160 | 159 | { |
161 | 160 | $error = array( 'product-item-price' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
162 | 161 | $view->errors = $view->get( 'errors', array() ) + $error; |
163 | 162 | |
164 | 163 | $textManager->rollback(); |
165 | 164 | $manager->rollback(); |
166 | - } |
|
167 | - catch( \Exception $e ) |
|
165 | + } catch( \Exception $e ) |
|
168 | 166 | { |
169 | 167 | $context->getLogger()->log( $e->getMessage() . ' - ' . $e->getTraceAsString() ); |
170 | 168 | $error = array( 'product-item-price' => $e->getMessage() ); |
@@ -365,8 +363,7 @@ discard block |
||
365 | 363 | |
366 | 364 | $item = $priceItem; |
367 | 365 | $item->setId( null ); |
368 | - } |
|
369 | - else |
|
366 | + } else |
|
370 | 367 | { |
371 | 368 | $litem = $listItems[$listid]; |
372 | 369 | $item = $litem->getRefItem(); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * Copies a resource |
65 | 65 | * |
66 | - * @return string|null admin output to display or null for redirecting to the list |
|
66 | + * @return string admin output to display or null for redirecting to the list |
|
67 | 67 | */ |
68 | 68 | public function copy() |
69 | 69 | { |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | /** |
87 | 87 | * Creates a new resource |
88 | 88 | * |
89 | - * @return string|null admin output to display or null for redirecting to the list |
|
89 | + * @return string admin output to display or null for redirecting to the list |
|
90 | 90 | */ |
91 | 91 | public function create() |
92 | 92 | { |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | /** |
110 | 110 | * Returns a single resource |
111 | 111 | * |
112 | - * @return string|null admin output to display or null for redirecting to the list |
|
112 | + * @return string admin output to display or null for redirecting to the list |
|
113 | 113 | */ |
114 | 114 | public function get() |
115 | 115 | { |
@@ -67,17 +67,17 @@ discard block |
||
67 | 67 | { |
68 | 68 | $view = $this->getView(); |
69 | 69 | |
70 | - $this->setData( $view ); |
|
70 | + $this->setData($view); |
|
71 | 71 | $view->bundleBody = ''; |
72 | 72 | |
73 | - foreach( $this->getSubClients() as $client ) { |
|
73 | + foreach ($this->getSubClients() as $client) { |
|
74 | 74 | $view->bundleBody .= $client->copy(); |
75 | 75 | } |
76 | 76 | |
77 | 77 | $tplconf = 'admin/jqadm/product/bundle/template-item'; |
78 | 78 | $default = 'product/item-bundle-default.php'; |
79 | 79 | |
80 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
80 | + return $view->render($view->config($tplconf, $default)); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -90,17 +90,17 @@ discard block |
||
90 | 90 | { |
91 | 91 | $view = $this->getView(); |
92 | 92 | |
93 | - $this->setData( $view ); |
|
93 | + $this->setData($view); |
|
94 | 94 | $view->bundleBody = ''; |
95 | 95 | |
96 | - foreach( $this->getSubClients() as $client ) { |
|
96 | + foreach ($this->getSubClients() as $client) { |
|
97 | 97 | $view->bundleBody .= $client->create(); |
98 | 98 | } |
99 | 99 | |
100 | 100 | $tplconf = 'admin/jqadm/product/bundle/template-item'; |
101 | 101 | $default = 'product/item-bundle-default.php'; |
102 | 102 | |
103 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
103 | + return $view->render($view->config($tplconf, $default)); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | |
@@ -113,17 +113,17 @@ discard block |
||
113 | 113 | { |
114 | 114 | $view = $this->getView(); |
115 | 115 | |
116 | - $this->setData( $view ); |
|
116 | + $this->setData($view); |
|
117 | 117 | $view->bundleBody = ''; |
118 | 118 | |
119 | - foreach( $this->getSubClients() as $client ) { |
|
119 | + foreach ($this->getSubClients() as $client) { |
|
120 | 120 | $view->bundleBody .= $client->get(); |
121 | 121 | } |
122 | 122 | |
123 | 123 | $tplconf = 'admin/jqadm/product/bundle/template-item'; |
124 | 124 | $default = 'product/item-bundle-default.php'; |
125 | 125 | |
126 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
126 | + return $view->render($view->config($tplconf, $default)); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
@@ -137,32 +137,32 @@ discard block |
||
137 | 137 | $view = $this->getView(); |
138 | 138 | $context = $this->getContext(); |
139 | 139 | |
140 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' ); |
|
140 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); |
|
141 | 141 | $manager->begin(); |
142 | 142 | |
143 | 143 | try |
144 | 144 | { |
145 | - $this->updateItems( $view ); |
|
145 | + $this->updateItems($view); |
|
146 | 146 | $view->bundleBody = ''; |
147 | 147 | |
148 | - foreach( $this->getSubClients() as $client ) { |
|
148 | + foreach ($this->getSubClients() as $client) { |
|
149 | 149 | $view->bundleBody .= $client->save(); |
150 | 150 | } |
151 | 151 | |
152 | 152 | $manager->commit(); |
153 | 153 | return; |
154 | 154 | } |
155 | - catch( \Aimeos\MShop\Exception $e ) |
|
155 | + catch (\Aimeos\MShop\Exception $e) |
|
156 | 156 | { |
157 | - $error = array( 'product-item-bundle' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
|
158 | - $view->errors = $view->get( 'errors', array() ) + $error; |
|
157 | + $error = array('product-item-bundle' => $context->getI18n()->dt('mshop', $e->getMessage())); |
|
158 | + $view->errors = $view->get('errors', array()) + $error; |
|
159 | 159 | $manager->rollback(); |
160 | 160 | } |
161 | - catch( \Exception $e ) |
|
161 | + catch (\Exception $e) |
|
162 | 162 | { |
163 | - $context->getLogger()->log( $e->getMessage() . ' - ' . $e->getTraceAsString() ); |
|
164 | - $error = array( 'product-item-bundle' => $e->getMessage() ); |
|
165 | - $view->errors = $view->get( 'errors', array() ) + $error; |
|
163 | + $context->getLogger()->log($e->getMessage() . ' - ' . $e->getTraceAsString()); |
|
164 | + $error = array('product-item-bundle' => $e->getMessage()); |
|
165 | + $view->errors = $view->get('errors', array()) + $error; |
|
166 | 166 | $manager->rollback(); |
167 | 167 | } |
168 | 168 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @param string|null $name Name of the sub-client (Default if null) |
178 | 178 | * @return \Aimeos\Admin\JQAdm\Iface Sub-client object |
179 | 179 | */ |
180 | - public function getSubClient( $type, $name = null ) |
|
180 | + public function getSubClient($type, $name = null) |
|
181 | 181 | { |
182 | 182 | /** admin/jqadm/product/bundle/decorators/excludes |
183 | 183 | * Excludes decorators added by the "common" option from the product JQAdm client |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @see admin/jqadm/product/bundle/decorators/excludes |
253 | 253 | * @see admin/jqadm/product/bundle/decorators/global |
254 | 254 | */ |
255 | - return $this->createSubClient( 'product/bundle/' . $type, $name ); |
|
255 | + return $this->createSubClient('product/bundle/' . $type, $name); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | */ |
264 | 264 | protected function getSubClientNames() |
265 | 265 | { |
266 | - return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames ); |
|
266 | + return $this->getContext()->getConfig()->get($this->subPartPath, $this->subPartNames); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -273,20 +273,20 @@ discard block |
||
273 | 273 | * @param string $prodid Unique product ID |
274 | 274 | * @return array Associative list of bundle product IDs as keys and list items as values |
275 | 275 | */ |
276 | - protected function getListItems( $prodid ) |
|
276 | + protected function getListItems($prodid) |
|
277 | 277 | { |
278 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' ); |
|
278 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists'); |
|
279 | 279 | |
280 | 280 | $search = $manager->createSearch(); |
281 | 281 | $expr = array( |
282 | - $search->compare( '==', 'product.lists.parentid', $prodid ), |
|
283 | - $search->compare( '==', 'product.lists.domain', 'product' ), |
|
284 | - $search->compare( '==', 'product.lists.type.domain', 'product' ), |
|
285 | - $search->compare( '==', 'product.lists.type.code', 'default' ), |
|
282 | + $search->compare('==', 'product.lists.parentid', $prodid), |
|
283 | + $search->compare('==', 'product.lists.domain', 'product'), |
|
284 | + $search->compare('==', 'product.lists.type.domain', 'product'), |
|
285 | + $search->compare('==', 'product.lists.type.code', 'default'), |
|
286 | 286 | ); |
287 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
287 | + $search->setConditions($search->combine('&&', $expr)); |
|
288 | 288 | |
289 | - return $manager->searchItems( $search ); |
|
289 | + return $manager->searchItems($search); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | |
@@ -295,18 +295,18 @@ discard block |
||
295 | 295 | * |
296 | 296 | * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters |
297 | 297 | */ |
298 | - protected function setData( \Aimeos\MW\View\Iface $view ) |
|
298 | + protected function setData(\Aimeos\MW\View\Iface $view) |
|
299 | 299 | { |
300 | - $data = (array) $view->param( 'bundle', array() ); |
|
300 | + $data = (array) $view->param('bundle', array()); |
|
301 | 301 | |
302 | - if( empty( $data ) ) |
|
302 | + if (empty($data)) |
|
303 | 303 | { |
304 | - foreach( $view->item->getListItems( 'product', 'default' ) as $listItem ) |
|
304 | + foreach ($view->item->getListItems('product', 'default') as $listItem) |
|
305 | 305 | { |
306 | 306 | $refItem = $listItem->getRefItem(); |
307 | - $data['product.label'][] = ( $refItem ? $refItem->getLabel() : '' ); |
|
307 | + $data['product.label'][] = ($refItem ? $refItem->getLabel() : ''); |
|
308 | 308 | |
309 | - foreach( $listItem->toArray() as $key => $value ) { |
|
309 | + foreach ($listItem->toArray() as $key => $value) { |
|
310 | 310 | $data[$key][] = $value; |
311 | 311 | } |
312 | 312 | } |
@@ -321,43 +321,43 @@ discard block |
||
321 | 321 | * |
322 | 322 | * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters |
323 | 323 | */ |
324 | - protected function updateItems( \Aimeos\MW\View\Iface $view ) |
|
324 | + protected function updateItems(\Aimeos\MW\View\Iface $view) |
|
325 | 325 | { |
326 | - if( $view->item->getType() !== 'bundle' ) { |
|
326 | + if ($view->item->getType() !== 'bundle') { |
|
327 | 327 | return; |
328 | 328 | } |
329 | 329 | |
330 | 330 | $context = $this->getContext(); |
331 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' ); |
|
332 | - $typeManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists/type' ); |
|
331 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); |
|
332 | + $typeManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists/type'); |
|
333 | 333 | |
334 | 334 | $id = $view->item->getId(); |
335 | - $map = $this->getListItems( $id ); |
|
336 | - $listIds = (array) $view->param( 'bundle/product.lists.id', array() ); |
|
335 | + $map = $this->getListItems($id); |
|
336 | + $listIds = (array) $view->param('bundle/product.lists.id', array()); |
|
337 | 337 | |
338 | 338 | |
339 | - foreach( $listIds as $pos => $listid ) |
|
339 | + foreach ($listIds as $pos => $listid) |
|
340 | 340 | { |
341 | - if( isset( $map[$listid] ) ) { |
|
342 | - unset( $map[$listid], $listIds[$pos] ); |
|
341 | + if (isset($map[$listid])) { |
|
342 | + unset($map[$listid], $listIds[$pos]); |
|
343 | 343 | } |
344 | 344 | } |
345 | 345 | |
346 | - $manager->deleteItems( array_keys( $map ) ); |
|
346 | + $manager->deleteItems(array_keys($map)); |
|
347 | 347 | |
348 | 348 | |
349 | 349 | $item = $manager->createItem(); |
350 | - $item->setTypeId( $typeManager->findItem( 'default', array(), 'product' )->getId() ); |
|
351 | - $item->setDomain( 'product' ); |
|
352 | - $item->setParentId( $id ); |
|
350 | + $item->setTypeId($typeManager->findItem('default', array(), 'product')->getId()); |
|
351 | + $item->setDomain('product'); |
|
352 | + $item->setParentId($id); |
|
353 | 353 | |
354 | - foreach( $listIds as $pos => $listid ) |
|
354 | + foreach ($listIds as $pos => $listid) |
|
355 | 355 | { |
356 | - $item->setId( null ); |
|
357 | - $item->setRefId( $view->param( 'bundle/product.lists.refid/' . $pos ) ); |
|
358 | - $item->setPosition( $pos ); |
|
356 | + $item->setId(null); |
|
357 | + $item->setRefId($view->param('bundle/product.lists.refid/' . $pos)); |
|
358 | + $item->setPosition($pos); |
|
359 | 359 | |
360 | - $manager->saveItem( $item, false ); |
|
360 | + $manager->saveItem($item, false); |
|
361 | 361 | } |
362 | 362 | } |
363 | 363 | } |
364 | 364 | \ No newline at end of file |
@@ -151,14 +151,12 @@ |
||
151 | 151 | |
152 | 152 | $manager->commit(); |
153 | 153 | return; |
154 | - } |
|
155 | - catch( \Aimeos\MShop\Exception $e ) |
|
154 | + } catch( \Aimeos\MShop\Exception $e ) |
|
156 | 155 | { |
157 | 156 | $error = array( 'product-item-category' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
158 | 157 | $view->errors = $view->get( 'errors', array() ) + $error; |
159 | 158 | $manager->rollback(); |
160 | - } |
|
161 | - catch( \Exception $e ) |
|
159 | + } catch( \Exception $e ) |
|
162 | 160 | { |
163 | 161 | $context->getLogger()->log( $e->getMessage() . ' - ' . $e->getTraceAsString() ); |
164 | 162 | $error = array( 'product-item-category' => $e->getMessage() ); |
@@ -67,17 +67,17 @@ discard block |
||
67 | 67 | { |
68 | 68 | $view = $this->getView(); |
69 | 69 | |
70 | - $this->setData( $view ); |
|
70 | + $this->setData($view); |
|
71 | 71 | $view->stockBody = ''; |
72 | 72 | |
73 | - foreach( $this->getSubClients() as $client ) { |
|
73 | + foreach ($this->getSubClients() as $client) { |
|
74 | 74 | $view->stockBody .= $client->copy(); |
75 | 75 | } |
76 | 76 | |
77 | 77 | $tplconf = 'admin/jqadm/product/stock/template-item'; |
78 | 78 | $default = 'product/item-stock-default.php'; |
79 | 79 | |
80 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
80 | + return $view->render($view->config($tplconf, $default)); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -90,17 +90,17 @@ discard block |
||
90 | 90 | { |
91 | 91 | $view = $this->getView(); |
92 | 92 | |
93 | - $this->setData( $view ); |
|
93 | + $this->setData($view); |
|
94 | 94 | $view->stockBody = ''; |
95 | 95 | |
96 | - foreach( $this->getSubClients() as $client ) { |
|
96 | + foreach ($this->getSubClients() as $client) { |
|
97 | 97 | $view->stockBody .= $client->create(); |
98 | 98 | } |
99 | 99 | |
100 | 100 | $tplconf = 'admin/jqadm/product/stock/template-item'; |
101 | 101 | $default = 'product/item-stock-default.php'; |
102 | 102 | |
103 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
103 | + return $view->render($view->config($tplconf, $default)); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | |
@@ -113,17 +113,17 @@ discard block |
||
113 | 113 | { |
114 | 114 | $view = $this->getView(); |
115 | 115 | |
116 | - $this->setData( $view ); |
|
116 | + $this->setData($view); |
|
117 | 117 | $view->stockBody = ''; |
118 | 118 | |
119 | - foreach( $this->getSubClients() as $client ) { |
|
119 | + foreach ($this->getSubClients() as $client) { |
|
120 | 120 | $view->stockBody .= $client->get(); |
121 | 121 | } |
122 | 122 | |
123 | 123 | $tplconf = 'admin/jqadm/product/stock/template-item'; |
124 | 124 | $default = 'product/item-stock-default.php'; |
125 | 125 | |
126 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
126 | + return $view->render($view->config($tplconf, $default)); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
@@ -137,32 +137,32 @@ discard block |
||
137 | 137 | $view = $this->getView(); |
138 | 138 | $context = $this->getContext(); |
139 | 139 | |
140 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product/stock' ); |
|
140 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product/stock'); |
|
141 | 141 | $manager->begin(); |
142 | 142 | |
143 | 143 | try |
144 | 144 | { |
145 | - $this->updateItems( $view ); |
|
145 | + $this->updateItems($view); |
|
146 | 146 | $view->stockBody = ''; |
147 | 147 | |
148 | - foreach( $this->getSubClients() as $client ) { |
|
148 | + foreach ($this->getSubClients() as $client) { |
|
149 | 149 | $view->stockBody .= $client->save(); |
150 | 150 | } |
151 | 151 | |
152 | 152 | $manager->commit(); |
153 | 153 | return; |
154 | 154 | } |
155 | - catch( \Aimeos\MShop\Exception $e ) |
|
155 | + catch (\Aimeos\MShop\Exception $e) |
|
156 | 156 | { |
157 | - $error = array( 'product-item-stock' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
|
158 | - $view->errors = $view->get( 'errors', array() ) + $error; |
|
157 | + $error = array('product-item-stock' => $context->getI18n()->dt('mshop', $e->getMessage())); |
|
158 | + $view->errors = $view->get('errors', array()) + $error; |
|
159 | 159 | $manager->rollback(); |
160 | 160 | } |
161 | - catch( \Exception $e ) |
|
161 | + catch (\Exception $e) |
|
162 | 162 | { |
163 | - $context->getLogger()->log( $e->getMessage() . ' - ' . $e->getTraceAsString() ); |
|
164 | - $error = array( 'product-item-stock' => $e->getMessage() ); |
|
165 | - $view->errors = $view->get( 'errors', array() ) + $error; |
|
163 | + $context->getLogger()->log($e->getMessage() . ' - ' . $e->getTraceAsString()); |
|
164 | + $error = array('product-item-stock' => $e->getMessage()); |
|
165 | + $view->errors = $view->get('errors', array()) + $error; |
|
166 | 166 | $manager->rollback(); |
167 | 167 | } |
168 | 168 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @param string|null $name Name of the sub-client (Default if null) |
178 | 178 | * @return \Aimeos\Admin\JQAdm\Iface Sub-client object |
179 | 179 | */ |
180 | - public function getSubClient( $type, $name = null ) |
|
180 | + public function getSubClient($type, $name = null) |
|
181 | 181 | { |
182 | 182 | /** admin/jqadm/product/stock/decorators/excludes |
183 | 183 | * Excludes decorators added by the "common" option from the product JQAdm client |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @see admin/jqadm/product/stock/decorators/excludes |
253 | 253 | * @see admin/jqadm/product/stock/decorators/global |
254 | 254 | */ |
255 | - return $this->createSubClient( 'product/stock/' . $type, $name ); |
|
255 | + return $this->createSubClient('product/stock/' . $type, $name); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | */ |
264 | 264 | protected function getSubClientNames() |
265 | 265 | { |
266 | - return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames ); |
|
266 | + return $this->getContext()->getConfig()->get($this->subPartPath, $this->subPartNames); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -272,28 +272,28 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters |
274 | 274 | */ |
275 | - protected function setData( \Aimeos\MW\View\Iface $view ) |
|
275 | + protected function setData(\Aimeos\MW\View\Iface $view) |
|
276 | 276 | { |
277 | 277 | $context = $this->getContext(); |
278 | - $whManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/stock/warehouse' ); |
|
278 | + $whManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/stock/warehouse'); |
|
279 | 279 | |
280 | - $view->stockWarehouses = $whManager->searchItems( $whManager->createSearch() ); |
|
281 | - $view->stockData = (array) $view->param( 'stock', array() ); |
|
280 | + $view->stockWarehouses = $whManager->searchItems($whManager->createSearch()); |
|
281 | + $view->stockData = (array) $view->param('stock', array()); |
|
282 | 282 | |
283 | - if( !empty( $view->stockData ) || ( $id = $view->item->getId() ) === null ) { |
|
283 | + if (!empty($view->stockData) || ($id = $view->item->getId()) === null) { |
|
284 | 284 | return; |
285 | 285 | } |
286 | 286 | |
287 | 287 | $data = array(); |
288 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/stock' ); |
|
288 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/stock'); |
|
289 | 289 | |
290 | 290 | $search = $manager->createSearch(); |
291 | - $search->setConditions( $search->compare( '==', 'product.stock.parentid', $id ) ); |
|
292 | - $search->setSortations( array( $search->sort( '+', 'product.stock.warehouse.code' ) ) ); |
|
291 | + $search->setConditions($search->compare('==', 'product.stock.parentid', $id)); |
|
292 | + $search->setSortations(array($search->sort('+', 'product.stock.warehouse.code'))); |
|
293 | 293 | |
294 | - foreach( $manager->searchItems( $search ) as $item ) |
|
294 | + foreach ($manager->searchItems($search) as $item) |
|
295 | 295 | { |
296 | - foreach( $item->toArray() as $key => $value ) { |
|
296 | + foreach ($item->toArray() as $key => $value) { |
|
297 | 297 | $data[$key][] = $value; |
298 | 298 | } |
299 | 299 | } |
@@ -307,32 +307,32 @@ discard block |
||
307 | 307 | * |
308 | 308 | * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters |
309 | 309 | */ |
310 | - protected function updateItems( \Aimeos\MW\View\Iface $view ) |
|
310 | + protected function updateItems(\Aimeos\MW\View\Iface $view) |
|
311 | 311 | { |
312 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/stock' ); |
|
312 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/stock'); |
|
313 | 313 | |
314 | 314 | $search = $manager->createSearch(); |
315 | - $search->setConditions( $search->compare( '==', 'product.stock.parentid', $view->item->getId() ) ); |
|
316 | - $items = $manager->searchitems( $search ); |
|
315 | + $search->setConditions($search->compare('==', 'product.stock.parentid', $view->item->getId())); |
|
316 | + $items = $manager->searchitems($search); |
|
317 | 317 | |
318 | - $list = (array) $view->param( 'stock/product.stock.id', array() ); |
|
318 | + $list = (array) $view->param('stock/product.stock.id', array()); |
|
319 | 319 | |
320 | - foreach( $list as $idx => $id ) |
|
320 | + foreach ($list as $idx => $id) |
|
321 | 321 | { |
322 | - if( !isset( $items[$id] ) ) { |
|
322 | + if (!isset($items[$id])) { |
|
323 | 323 | $item = $manager->createItem(); |
324 | 324 | } else { |
325 | 325 | $item = $items[$id]; |
326 | 326 | } |
327 | 327 | |
328 | - $item->setParentId( $view->item->getId() ); |
|
329 | - $item->setWarehouseId( $view->param( 'stock/product.stock.warehouseid/' . $idx ) ); |
|
330 | - $item->setStocklevel( $view->param( 'stock/product.stock.stocklevel/' . $idx ) ); |
|
331 | - $item->setDateBack( $view->param( 'stock/product.stock.dateback/' . $idx ) ); |
|
328 | + $item->setParentId($view->item->getId()); |
|
329 | + $item->setWarehouseId($view->param('stock/product.stock.warehouseid/' . $idx)); |
|
330 | + $item->setStocklevel($view->param('stock/product.stock.stocklevel/' . $idx)); |
|
331 | + $item->setDateBack($view->param('stock/product.stock.dateback/' . $idx)); |
|
332 | 332 | |
333 | - $manager->saveItem( $item, false ); |
|
333 | + $manager->saveItem($item, false); |
|
334 | 334 | } |
335 | 335 | |
336 | - $manager->deleteItems( array_diff( array_keys( $items ), $list ) ); |
|
336 | + $manager->deleteItems(array_diff(array_keys($items), $list)); |
|
337 | 337 | } |
338 | 338 | } |
@@ -151,14 +151,12 @@ |
||
151 | 151 | |
152 | 152 | $manager->commit(); |
153 | 153 | return; |
154 | - } |
|
155 | - catch( \Aimeos\MShop\Exception $e ) |
|
154 | + } catch( \Aimeos\MShop\Exception $e ) |
|
156 | 155 | { |
157 | 156 | $error = array( 'product-item-category' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
158 | 157 | $view->errors = $view->get( 'errors', array() ) + $error; |
159 | 158 | $manager->rollback(); |
160 | - } |
|
161 | - catch( \Exception $e ) |
|
159 | + } catch( \Exception $e ) |
|
162 | 160 | { |
163 | 161 | $context->getLogger()->log( $e->getMessage() . ' - ' . $e->getTraceAsString() ); |
164 | 162 | $error = array( 'product-item-category' => $e->getMessage() ); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * Copies a resource |
65 | 65 | * |
66 | - * @return string|null admin output to display or null for redirecting to the list |
|
66 | + * @return string admin output to display or null for redirecting to the list |
|
67 | 67 | */ |
68 | 68 | public function copy() |
69 | 69 | { |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | /** |
87 | 87 | * Creates a new resource |
88 | 88 | * |
89 | - * @return string|null admin output to display or null for redirecting to the list |
|
89 | + * @return string admin output to display or null for redirecting to the list |
|
90 | 90 | */ |
91 | 91 | public function create() |
92 | 92 | { |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | /** |
110 | 110 | * Returns a single resource |
111 | 111 | * |
112 | - * @return string|null admin output to display or null for redirecting to the list |
|
112 | + * @return string admin output to display or null for redirecting to the list |
|
113 | 113 | */ |
114 | 114 | public function get() |
115 | 115 | { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | private $subPartPath = 'admin/jqadm/product/text/standard/subparts'; |
58 | 58 | private $subPartNames = array(); |
59 | 59 | private $types; |
60 | - private $typelist = array( 'name', 'short', 'long', 'url', 'meta-keyword', 'meta-description' ); |
|
60 | + private $typelist = array('name', 'short', 'long', 'url', 'meta-keyword', 'meta-description'); |
|
61 | 61 | |
62 | 62 | |
63 | 63 | /** |
@@ -69,17 +69,17 @@ discard block |
||
69 | 69 | { |
70 | 70 | $view = $this->getView(); |
71 | 71 | |
72 | - $this->setData( $view ); |
|
72 | + $this->setData($view); |
|
73 | 73 | $view->textBody = ''; |
74 | 74 | |
75 | - foreach( $this->getSubClients() as $client ) { |
|
75 | + foreach ($this->getSubClients() as $client) { |
|
76 | 76 | $view->textBody .= $client->copy(); |
77 | 77 | } |
78 | 78 | |
79 | 79 | $tplconf = 'admin/jqadm/product/text/template-item'; |
80 | 80 | $default = 'product/item-text-default.php'; |
81 | 81 | |
82 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
82 | + return $view->render($view->config($tplconf, $default)); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
@@ -92,17 +92,17 @@ discard block |
||
92 | 92 | { |
93 | 93 | $view = $this->getView(); |
94 | 94 | |
95 | - $this->setData( $view ); |
|
95 | + $this->setData($view); |
|
96 | 96 | $view->textBody = ''; |
97 | 97 | |
98 | - foreach( $this->getSubClients() as $client ) { |
|
98 | + foreach ($this->getSubClients() as $client) { |
|
99 | 99 | $view->textBody .= $client->create(); |
100 | 100 | } |
101 | 101 | |
102 | 102 | $tplconf = 'admin/jqadm/product/text/template-item'; |
103 | 103 | $default = 'product/item-text-default.php'; |
104 | 104 | |
105 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
105 | + return $view->render($view->config($tplconf, $default)); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
@@ -115,17 +115,17 @@ discard block |
||
115 | 115 | { |
116 | 116 | $view = $this->getView(); |
117 | 117 | |
118 | - $this->setData( $view ); |
|
118 | + $this->setData($view); |
|
119 | 119 | $view->textBody = ''; |
120 | 120 | |
121 | - foreach( $this->getSubClients() as $client ) { |
|
121 | + foreach ($this->getSubClients() as $client) { |
|
122 | 122 | $view->textBody .= $client->get(); |
123 | 123 | } |
124 | 124 | |
125 | 125 | $tplconf = 'admin/jqadm/product/text/template-item'; |
126 | 126 | $default = 'product/item-text-default.php'; |
127 | 127 | |
128 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
128 | + return $view->render($view->config($tplconf, $default)); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
@@ -139,18 +139,18 @@ discard block |
||
139 | 139 | $view = $this->getView(); |
140 | 140 | $context = $this->getContext(); |
141 | 141 | |
142 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' ); |
|
143 | - $textManager = \Aimeos\MShop\Factory::createManager( $context, 'text' ); |
|
142 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); |
|
143 | + $textManager = \Aimeos\MShop\Factory::createManager($context, 'text'); |
|
144 | 144 | |
145 | 145 | $manager->begin(); |
146 | 146 | $textManager->begin(); |
147 | 147 | |
148 | 148 | try |
149 | 149 | { |
150 | - $this->updateItems( $view ); |
|
150 | + $this->updateItems($view); |
|
151 | 151 | $view->textBody = ''; |
152 | 152 | |
153 | - foreach( $this->getSubClients() as $client ) { |
|
153 | + foreach ($this->getSubClients() as $client) { |
|
154 | 154 | $view->textBody .= $client->save(); |
155 | 155 | } |
156 | 156 | |
@@ -158,19 +158,19 @@ discard block |
||
158 | 158 | $manager->commit(); |
159 | 159 | return; |
160 | 160 | } |
161 | - catch( \Aimeos\MShop\Exception $e ) |
|
161 | + catch (\Aimeos\MShop\Exception $e) |
|
162 | 162 | { |
163 | - $error = array( 'product-item-text' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
|
164 | - $view->errors = $view->get( 'errors', array() ) + $error; |
|
163 | + $error = array('product-item-text' => $context->getI18n()->dt('mshop', $e->getMessage())); |
|
164 | + $view->errors = $view->get('errors', array()) + $error; |
|
165 | 165 | |
166 | 166 | $textManager->rollback(); |
167 | 167 | $manager->rollback(); |
168 | 168 | } |
169 | - catch( \Exception $e ) |
|
169 | + catch (\Exception $e) |
|
170 | 170 | { |
171 | - $context->getLogger()->log( $e->getMessage() . ' - ' . $e->getTraceAsString() ); |
|
172 | - $error = array( 'product-item-text' => $e->getMessage() ); |
|
173 | - $view->errors = $view->get( 'errors', array() ) + $error; |
|
171 | + $context->getLogger()->log($e->getMessage() . ' - ' . $e->getTraceAsString()); |
|
172 | + $error = array('product-item-text' => $e->getMessage()); |
|
173 | + $view->errors = $view->get('errors', array()) + $error; |
|
174 | 174 | |
175 | 175 | $textManager->rollback(); |
176 | 176 | $manager->rollback(); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @param string|null $name Name of the sub-client (Default if null) |
188 | 188 | * @return \Aimeos\Admin\JQAdm\Iface Sub-client object |
189 | 189 | */ |
190 | - public function getSubClient( $type, $name = null ) |
|
190 | + public function getSubClient($type, $name = null) |
|
191 | 191 | { |
192 | 192 | /** admin/jqadm/product/text/decorators/excludes |
193 | 193 | * Excludes decorators added by the "common" option from the product JQAdm client |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @see admin/jqadm/product/text/decorators/excludes |
263 | 263 | * @see admin/jqadm/product/text/decorators/global |
264 | 264 | */ |
265 | - return $this->createSubClient( 'product/text/' . $type, $name ); |
|
265 | + return $this->createSubClient('product/text/' . $type, $name); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | */ |
274 | 274 | protected function getSubClientNames() |
275 | 275 | { |
276 | - return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames ); |
|
276 | + return $this->getContext()->getConfig()->get($this->subPartPath, $this->subPartNames); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | |
@@ -284,26 +284,26 @@ discard block |
||
284 | 284 | * @return integer Type ID for the given type |
285 | 285 | * @throws \Aimeos\Admin\JQAdm\Exception If the given type is unknown |
286 | 286 | */ |
287 | - protected function getTypeId( $type ) |
|
287 | + protected function getTypeId($type) |
|
288 | 288 | { |
289 | - if( $this->types === null ) |
|
289 | + if ($this->types === null) |
|
290 | 290 | { |
291 | 291 | $this->types = array(); |
292 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'text/type' ); |
|
292 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'text/type'); |
|
293 | 293 | |
294 | 294 | $search = $manager->createSearch(); |
295 | - $search->setConditions( $search->compare( '==', 'text.type.domain', 'product' ) ); |
|
295 | + $search->setConditions($search->compare('==', 'text.type.domain', 'product')); |
|
296 | 296 | |
297 | - foreach( $manager->searchItems( $search ) as $id => $typeItem ) { |
|
297 | + foreach ($manager->searchItems($search) as $id => $typeItem) { |
|
298 | 298 | $this->types[$typeItem->getCode()] = $id; |
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
302 | - if( isset( $this->types[$type] ) ) { |
|
302 | + if (isset($this->types[$type])) { |
|
303 | 303 | return $this->types[$type]; |
304 | 304 | } |
305 | 305 | |
306 | - throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Unknown type "%1$s"', $type ) ); |
|
306 | + throw new \Aimeos\Admin\JQAdm\Exception(sprintf('Unknown type "%1$s"', $type)); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | |
@@ -312,29 +312,29 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters |
314 | 314 | */ |
315 | - protected function setData( \Aimeos\MW\View\Iface $view ) |
|
315 | + protected function setData(\Aimeos\MW\View\Iface $view) |
|
316 | 316 | { |
317 | 317 | $context = $this->getContext(); |
318 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'text/type' ); |
|
318 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'text/type'); |
|
319 | 319 | |
320 | - $data = (array) $view->param( 'text', array() ); |
|
320 | + $data = (array) $view->param('text', array()); |
|
321 | 321 | |
322 | - if( empty( $data ) && ( $id = $view->item->getId() ) !== null ) |
|
322 | + if (empty($data) && ($id = $view->item->getId()) !== null) |
|
323 | 323 | { |
324 | - if( !isset( $data['langid'] ) ) { |
|
324 | + if (!isset($data['langid'])) { |
|
325 | 325 | $data['langid'] = array(); |
326 | 326 | } |
327 | 327 | |
328 | - foreach( $view->item->getListItems( 'text', 'default' ) as $listItem ) |
|
328 | + foreach ($view->item->getListItems('text', 'default') as $listItem) |
|
329 | 329 | { |
330 | - if( ( $refItem = $listItem->getRefItem() ) === null ) { |
|
330 | + if (($refItem = $listItem->getRefItem()) === null) { |
|
331 | 331 | continue; |
332 | 332 | } |
333 | 333 | |
334 | 334 | $type = $refItem->getType(); |
335 | 335 | $langid = $refItem->getLanguageId(); |
336 | 336 | |
337 | - if( in_array( $type, $this->typelist ) ) |
|
337 | + if (in_array($type, $this->typelist)) |
|
338 | 338 | { |
339 | 339 | $data['langid'][$langid] = $langid; |
340 | 340 | $data[$type]['listid'][$langid] = $listItem->getId(); |
@@ -343,11 +343,11 @@ discard block |
||
343 | 343 | } |
344 | 344 | } |
345 | 345 | |
346 | - if( !isset( $data['langid'] ) || empty( $data['langid'] ) ) { // show at least one block |
|
346 | + if (!isset($data['langid']) || empty($data['langid'])) { // show at least one block |
|
347 | 347 | $data['langid'][] = $context->getLocale()->getLanguageId(); |
348 | 348 | } |
349 | 349 | |
350 | - $view->textTypes = $manager->searchItems( $manager->createSearch() ); |
|
350 | + $view->textTypes = $manager->searchItems($manager->createSearch()); |
|
351 | 351 | $view->textData = $data; |
352 | 352 | } |
353 | 353 | |
@@ -357,50 +357,50 @@ discard block |
||
357 | 357 | * |
358 | 358 | * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters |
359 | 359 | */ |
360 | - protected function updateItems( \Aimeos\MW\View\Iface $view ) |
|
360 | + protected function updateItems(\Aimeos\MW\View\Iface $view) |
|
361 | 361 | { |
362 | 362 | $id = $view->item->getId(); |
363 | 363 | $context = $this->getContext(); |
364 | 364 | |
365 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
366 | - $textManager = \Aimeos\MShop\Factory::createManager( $context, 'text' ); |
|
367 | - $listManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' ); |
|
368 | - $listTypeManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists/type' ); |
|
365 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
366 | + $textManager = \Aimeos\MShop\Factory::createManager($context, 'text'); |
|
367 | + $listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); |
|
368 | + $listTypeManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists/type'); |
|
369 | 369 | |
370 | 370 | $listIds = array(); |
371 | - $langIds = (array) $view->param( 'text/langid', array() ); |
|
372 | - $listItems = $manager->getItem( $id, array( 'text' ) )->getListItems( 'text', 'default' ); |
|
371 | + $langIds = (array) $view->param('text/langid', array()); |
|
372 | + $listItems = $manager->getItem($id, array('text'))->getListItems('text', 'default'); |
|
373 | 373 | |
374 | 374 | |
375 | 375 | $listItem = $listManager->createItem(); |
376 | - $listItem->setTypeId( $listTypeManager->findItem( 'default', array(), 'text' )->getId() ); |
|
377 | - $listItem->setDomain( 'text' ); |
|
378 | - $listItem->setParentId( $id ); |
|
379 | - $listItem->setStatus( 1 ); |
|
376 | + $listItem->setTypeId($listTypeManager->findItem('default', array(), 'text')->getId()); |
|
377 | + $listItem->setDomain('text'); |
|
378 | + $listItem->setParentId($id); |
|
379 | + $listItem->setStatus(1); |
|
380 | 380 | |
381 | 381 | $textItem = $textManager->createItem(); |
382 | - $textItem->setDomain( 'product' ); |
|
383 | - $textItem->setStatus( 1 ); |
|
382 | + $textItem->setDomain('product'); |
|
383 | + $textItem->setStatus(1); |
|
384 | 384 | |
385 | 385 | |
386 | - foreach( $langIds as $idx => $langid ) |
|
386 | + foreach ($langIds as $idx => $langid) |
|
387 | 387 | { |
388 | - foreach( $this->typelist as $type ) |
|
388 | + foreach ($this->typelist as $type) |
|
389 | 389 | { |
390 | - if( ( $content = trim( $view->param( 'text/' . $type . '/content/' . $idx ) ) ) === '' ) { |
|
390 | + if (($content = trim($view->param('text/' . $type . '/content/' . $idx))) === '') { |
|
391 | 391 | continue; |
392 | 392 | } |
393 | 393 | |
394 | - $listid = $view->param( 'text/' . $type . '/listid/' . $idx ); |
|
394 | + $listid = $view->param('text/' . $type . '/listid/' . $idx); |
|
395 | 395 | $listIds[] = $listid; |
396 | 396 | |
397 | - if( !isset( $listItems[$listid] ) ) |
|
397 | + if (!isset($listItems[$listid])) |
|
398 | 398 | { |
399 | 399 | $litem = $listItem; |
400 | - $litem->setId( null ); |
|
400 | + $litem->setId(null); |
|
401 | 401 | |
402 | 402 | $item = $textItem; |
403 | - $item->setId( null ); |
|
403 | + $item->setId(null); |
|
404 | 404 | } |
405 | 405 | else |
406 | 406 | { |
@@ -408,37 +408,37 @@ discard block |
||
408 | 408 | $item = $litem->getRefItem(); |
409 | 409 | } |
410 | 410 | |
411 | - $item->setContent( $content ); |
|
412 | - $item->setLabel( mb_strcut( $item->getContent(), 0, 255 ) ); |
|
413 | - $item->setTypeId( $this->getTypeId( $type ) ); |
|
414 | - $item->setLanguageId( $langid ); |
|
411 | + $item->setContent($content); |
|
412 | + $item->setLabel(mb_strcut($item->getContent(), 0, 255)); |
|
413 | + $item->setTypeId($this->getTypeId($type)); |
|
414 | + $item->setLanguageId($langid); |
|
415 | 415 | |
416 | - $textManager->saveItem( $item ); |
|
416 | + $textManager->saveItem($item); |
|
417 | 417 | |
418 | - $litem->setPosition( $idx ); |
|
419 | - $litem->setRefId( $item->getId() ); |
|
418 | + $litem->setPosition($idx); |
|
419 | + $litem->setRefId($item->getId()); |
|
420 | 420 | |
421 | - $listManager->saveItem( $litem, false ); |
|
421 | + $listManager->saveItem($litem, false); |
|
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
425 | 425 | |
426 | 426 | $rmIds = $allListIds = array(); |
427 | 427 | |
428 | - foreach( $listItems as $id => $listItem ) |
|
428 | + foreach ($listItems as $id => $listItem) |
|
429 | 429 | { |
430 | - if( in_array( $listItem->getType(), $this->typelist ) ) { |
|
430 | + if (in_array($listItem->getType(), $this->typelist)) { |
|
431 | 431 | $allListIds[] = $id; |
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
435 | - $rmListIds = array_diff( $allListIds, $listIds ); |
|
435 | + $rmListIds = array_diff($allListIds, $listIds); |
|
436 | 436 | |
437 | - foreach( $rmListIds as $id ) { |
|
437 | + foreach ($rmListIds as $id) { |
|
438 | 438 | $rmIds[] = $listItems[$id]->getRefId(); |
439 | 439 | } |
440 | 440 | |
441 | - $listManager->deleteItems( $rmListIds ); |
|
442 | - $textManager->deleteItems( $rmIds ); |
|
441 | + $listManager->deleteItems($rmListIds); |
|
442 | + $textManager->deleteItems($rmIds); |
|
443 | 443 | } |
444 | 444 | } |
@@ -157,16 +157,14 @@ discard block |
||
157 | 157 | $textManager->commit(); |
158 | 158 | $manager->commit(); |
159 | 159 | return; |
160 | - } |
|
161 | - catch( \Aimeos\MShop\Exception $e ) |
|
160 | + } catch( \Aimeos\MShop\Exception $e ) |
|
162 | 161 | { |
163 | 162 | $error = array( 'product-item-text' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
164 | 163 | $view->errors = $view->get( 'errors', array() ) + $error; |
165 | 164 | |
166 | 165 | $textManager->rollback(); |
167 | 166 | $manager->rollback(); |
168 | - } |
|
169 | - catch( \Exception $e ) |
|
167 | + } catch( \Exception $e ) |
|
170 | 168 | { |
171 | 169 | $context->getLogger()->log( $e->getMessage() . ' - ' . $e->getTraceAsString() ); |
172 | 170 | $error = array( 'product-item-text' => $e->getMessage() ); |
@@ -401,8 +399,7 @@ discard block |
||
401 | 399 | |
402 | 400 | $item = $textItem; |
403 | 401 | $item->setId( null ); |
404 | - } |
|
405 | - else |
|
402 | + } else |
|
406 | 403 | { |
407 | 404 | $litem = $listItems[$listid]; |
408 | 405 | $item = $litem->getRefItem(); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * Copies a resource |
65 | 65 | * |
66 | - * @return string|null admin output to display or null for redirecting to the list |
|
66 | + * @return string admin output to display or null for redirecting to the list |
|
67 | 67 | */ |
68 | 68 | public function copy() |
69 | 69 | { |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | /** |
87 | 87 | * Creates a new resource |
88 | 88 | * |
89 | - * @return string|null admin output to display or null for redirecting to the list |
|
89 | + * @return string admin output to display or null for redirecting to the list |
|
90 | 90 | */ |
91 | 91 | public function create() |
92 | 92 | { |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | /** |
110 | 110 | * Returns a single resource |
111 | 111 | * |
112 | - * @return string|null admin output to display or null for redirecting to the list |
|
112 | + * @return string admin output to display or null for redirecting to the list |
|
113 | 113 | */ |
114 | 114 | public function get() |
115 | 115 | { |
@@ -67,17 +67,17 @@ discard block |
||
67 | 67 | { |
68 | 68 | $view = $this->getView(); |
69 | 69 | |
70 | - $this->setData( $view, true ); |
|
70 | + $this->setData($view, true); |
|
71 | 71 | $view->selectionBody = ''; |
72 | 72 | |
73 | - foreach( $this->getSubClients() as $client ) { |
|
73 | + foreach ($this->getSubClients() as $client) { |
|
74 | 74 | $view->selectionBody .= $client->copy(); |
75 | 75 | } |
76 | 76 | |
77 | 77 | $tplconf = 'admin/jqadm/product/selection/template-item'; |
78 | 78 | $default = 'product/item-selection-default.php'; |
79 | 79 | |
80 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
80 | + return $view->render($view->config($tplconf, $default)); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -90,17 +90,17 @@ discard block |
||
90 | 90 | { |
91 | 91 | $view = $this->getView(); |
92 | 92 | |
93 | - $this->setData( $view ); |
|
93 | + $this->setData($view); |
|
94 | 94 | $view->selectionBody = ''; |
95 | 95 | |
96 | - foreach( $this->getSubClients() as $client ) { |
|
96 | + foreach ($this->getSubClients() as $client) { |
|
97 | 97 | $view->selectionBody .= $client->create(); |
98 | 98 | } |
99 | 99 | |
100 | 100 | $tplconf = 'admin/jqadm/product/selection/template-item'; |
101 | 101 | $default = 'product/item-selection-default.php'; |
102 | 102 | |
103 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
103 | + return $view->render($view->config($tplconf, $default)); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | |
@@ -113,17 +113,17 @@ discard block |
||
113 | 113 | { |
114 | 114 | $view = $this->getView(); |
115 | 115 | |
116 | - $this->setData( $view ); |
|
116 | + $this->setData($view); |
|
117 | 117 | $view->selectionBody = ''; |
118 | 118 | |
119 | - foreach( $this->getSubClients() as $client ) { |
|
119 | + foreach ($this->getSubClients() as $client) { |
|
120 | 120 | $view->selectionBody .= $client->get(); |
121 | 121 | } |
122 | 122 | |
123 | 123 | $tplconf = 'admin/jqadm/product/selection/template-item'; |
124 | 124 | $default = 'product/item-selection-default.php'; |
125 | 125 | |
126 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
126 | + return $view->render($view->config($tplconf, $default)); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
@@ -137,32 +137,32 @@ discard block |
||
137 | 137 | $view = $this->getView(); |
138 | 138 | $context = $this->getContext(); |
139 | 139 | |
140 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
140 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
141 | 141 | $manager->begin(); |
142 | 142 | |
143 | 143 | try |
144 | 144 | { |
145 | - $this->updateItems( $view ); |
|
145 | + $this->updateItems($view); |
|
146 | 146 | $view->selectionBody = ''; |
147 | 147 | |
148 | - foreach( $this->getSubClients() as $client ) { |
|
148 | + foreach ($this->getSubClients() as $client) { |
|
149 | 149 | $view->selectionBody .= $client->save(); |
150 | 150 | } |
151 | 151 | |
152 | 152 | $manager->commit(); |
153 | 153 | return; |
154 | 154 | } |
155 | - catch( \Aimeos\MShop\Exception $e ) |
|
155 | + catch (\Aimeos\MShop\Exception $e) |
|
156 | 156 | { |
157 | - $error = array( 'product-item-selection' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
|
158 | - $view->errors = $view->get( 'errors', array() ) + $error; |
|
157 | + $error = array('product-item-selection' => $context->getI18n()->dt('mshop', $e->getMessage())); |
|
158 | + $view->errors = $view->get('errors', array()) + $error; |
|
159 | 159 | $manager->rollback(); |
160 | 160 | } |
161 | - catch( \Exception $e ) |
|
161 | + catch (\Exception $e) |
|
162 | 162 | { |
163 | - $context->getLogger()->log( $e->getMessage() . ' - ' . $e->getTraceAsString() ); |
|
164 | - $error = array( 'product-item-selection' => $e->getMessage() ); |
|
165 | - $view->errors = $view->get( 'errors', array() ) + $error; |
|
163 | + $context->getLogger()->log($e->getMessage() . ' - ' . $e->getTraceAsString()); |
|
164 | + $error = array('product-item-selection' => $e->getMessage()); |
|
165 | + $view->errors = $view->get('errors', array()) + $error; |
|
166 | 166 | $manager->rollback(); |
167 | 167 | } |
168 | 168 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @param string|null $name Name of the sub-client (Default if null) |
178 | 178 | * @return \Aimeos\Admin\JQAdm\Iface Sub-client object |
179 | 179 | */ |
180 | - public function getSubClient( $type, $name = null ) |
|
180 | + public function getSubClient($type, $name = null) |
|
181 | 181 | { |
182 | 182 | /** admin/jqadm/product/selection/decorators/excludes |
183 | 183 | * Excludes decorators added by the "common" option from the product JQAdm client |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @see admin/jqadm/product/selection/decorators/excludes |
253 | 253 | * @see admin/jqadm/product/selection/decorators/global |
254 | 254 | */ |
255 | - return $this->createSubClient( 'product/selection/' . $type, $name ); |
|
255 | + return $this->createSubClient('product/selection/' . $type, $name); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | |
@@ -262,38 +262,38 @@ discard block |
||
262 | 262 | * @param array $listItems List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
263 | 263 | * @param array $listIds List of IDs of the still used list items |
264 | 264 | */ |
265 | - protected function cleanupItems( array $listItems, array $listIds ) |
|
265 | + protected function cleanupItems(array $listItems, array $listIds) |
|
266 | 266 | { |
267 | 267 | $context = $this->getContext(); |
268 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
269 | - $listManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' ); |
|
268 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
269 | + $listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); |
|
270 | 270 | |
271 | 271 | $rmIds = array(); |
272 | - $rmListIds = array_diff( array_keys( $listItems ), $listIds ); |
|
272 | + $rmListIds = array_diff(array_keys($listItems), $listIds); |
|
273 | 273 | |
274 | - foreach( $rmListIds as $rmListId ) { |
|
274 | + foreach ($rmListIds as $rmListId) { |
|
275 | 275 | $rmIds[] = $listItems[$rmListId]->getRefId(); |
276 | 276 | } |
277 | 277 | |
278 | 278 | $search = $listManager->createSearch(); |
279 | 279 | $expr = array( |
280 | - $search->compare( '==', 'product.lists.refid', $rmIds ), |
|
281 | - $search->compare( '==', 'product.lists.domain', 'product' ), |
|
282 | - $search->compare( '==', 'product.lists.type.code', 'default' ), |
|
283 | - $search->compare( '==', 'product.lists.type.domain', 'product' ), |
|
280 | + $search->compare('==', 'product.lists.refid', $rmIds), |
|
281 | + $search->compare('==', 'product.lists.domain', 'product'), |
|
282 | + $search->compare('==', 'product.lists.type.code', 'default'), |
|
283 | + $search->compare('==', 'product.lists.type.domain', 'product'), |
|
284 | 284 | ); |
285 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
286 | - $search->setSlice( 0, 0x7fffffff ); |
|
285 | + $search->setConditions($search->combine('&&', $expr)); |
|
286 | + $search->setSlice(0, 0x7fffffff); |
|
287 | 287 | |
288 | - foreach( $listManager->aggregate( $search, 'product.lists.refid' ) as $key => $count ) |
|
288 | + foreach ($listManager->aggregate($search, 'product.lists.refid') as $key => $count) |
|
289 | 289 | { |
290 | - if( $count > 1 ) { |
|
291 | - unset( $rmIds[$key] ); |
|
290 | + if ($count > 1) { |
|
291 | + unset($rmIds[$key]); |
|
292 | 292 | } |
293 | 293 | } |
294 | 294 | |
295 | - $listManager->deleteItems( $rmListIds ); |
|
296 | - $manager->deleteItems( $rmIds ); |
|
295 | + $listManager->deleteItems($rmListIds); |
|
296 | + $manager->deleteItems($rmIds); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | |
@@ -305,12 +305,12 @@ discard block |
||
305 | 305 | protected function createItem() |
306 | 306 | { |
307 | 307 | $context = $this->getContext(); |
308 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
309 | - $typeManager = \Aimeos\MShop\Factory::createManager( $context, 'product/type' ); |
|
308 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
309 | + $typeManager = \Aimeos\MShop\Factory::createManager($context, 'product/type'); |
|
310 | 310 | |
311 | 311 | $item = $manager->createItem(); |
312 | - $item->setTypeId( $typeManager->findItem( 'default', array(), 'product' )->getId() ); |
|
313 | - $item->setStatus( 1 ); |
|
312 | + $item->setTypeId($typeManager->findItem('default', array(), 'product')->getId()); |
|
313 | + $item->setStatus(1); |
|
314 | 314 | |
315 | 315 | return $item; |
316 | 316 | } |
@@ -322,17 +322,17 @@ discard block |
||
322 | 322 | * @param string $id Parent ID for the new list item |
323 | 323 | * @return \Aimeos\MShop\Common\Item\Lists\Iface New list item object |
324 | 324 | */ |
325 | - protected function createListItem( $id ) |
|
325 | + protected function createListItem($id) |
|
326 | 326 | { |
327 | 327 | $context = $this->getContext(); |
328 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' ); |
|
329 | - $typeManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists/type' ); |
|
328 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); |
|
329 | + $typeManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists/type'); |
|
330 | 330 | |
331 | 331 | $item = $manager->createItem(); |
332 | - $item->setTypeId( $typeManager->findItem( 'default', array(), 'product' )->getId() ); |
|
333 | - $item->setDomain( 'product' ); |
|
334 | - $item->setParentId( $id ); |
|
335 | - $item->setStatus( 1 ); |
|
332 | + $item->setTypeId($typeManager->findItem('default', array(), 'product')->getId()); |
|
333 | + $item->setDomain('product'); |
|
334 | + $item->setParentId($id); |
|
335 | + $item->setStatus(1); |
|
336 | 336 | |
337 | 337 | return $item; |
338 | 338 | } |
@@ -345,19 +345,19 @@ discard block |
||
345 | 345 | * @param array $ids List of product IDs |
346 | 346 | * @return array List of products with ID as key and items implementing \Aimeos\MShop\Product\Item\Iface as values |
347 | 347 | */ |
348 | - protected function getProductItems( array $codes, array $ids ) |
|
348 | + protected function getProductItems(array $codes, array $ids) |
|
349 | 349 | { |
350 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
350 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
351 | 351 | |
352 | 352 | $search = $manager->createSearch(); |
353 | 353 | $expr = array( |
354 | - $search->compare( '==', 'product.id', $ids ), |
|
355 | - $search->compare( '==', 'product.code', $codes ), |
|
354 | + $search->compare('==', 'product.id', $ids), |
|
355 | + $search->compare('==', 'product.code', $codes), |
|
356 | 356 | ); |
357 | - $search->setConditions( $search->combine( '||', $expr ) ); |
|
358 | - $search->setSlice( 0, 0x7fffffff ); |
|
357 | + $search->setConditions($search->combine('||', $expr)); |
|
358 | + $search->setSlice(0, 0x7fffffff); |
|
359 | 359 | |
360 | - return $manager->searchItems( $search, array( 'attribute' ) ); |
|
360 | + return $manager->searchItems($search, array('attribute')); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | |
@@ -368,25 +368,25 @@ discard block |
||
368 | 368 | * @param boolean $copy True if items should be copied |
369 | 369 | * @return array Multi-dimensional associative array |
370 | 370 | */ |
371 | - protected function getDataExisting( \Aimeos\MW\View\Iface $view, $copy = false ) |
|
371 | + protected function getDataExisting(\Aimeos\MW\View\Iface $view, $copy = false) |
|
372 | 372 | { |
373 | 373 | $data = array(); |
374 | - $variants = $view->item->getRefItems( 'product', null, 'default' ); |
|
375 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
374 | + $variants = $view->item->getRefItems('product', null, 'default'); |
|
375 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
376 | 376 | |
377 | 377 | $search = $manager->createSearch(); |
378 | - $search->setConditions( $search->compare( '==', 'product.id', array_keys( $variants ) ) ); |
|
379 | - $search->setSlice( 0, 0x7fffffff ); |
|
378 | + $search->setConditions($search->compare('==', 'product.id', array_keys($variants))); |
|
379 | + $search->setSlice(0, 0x7fffffff); |
|
380 | 380 | |
381 | - $products = $manager->searchItems( $search, array( 'attribute' ) ); |
|
381 | + $products = $manager->searchItems($search, array('attribute')); |
|
382 | 382 | |
383 | - foreach( $view->item->getListItems( 'product', 'default' ) as $listid => $listItem ) |
|
383 | + foreach ($view->item->getListItems('product', 'default') as $listid => $listItem) |
|
384 | 384 | { |
385 | - if( ( $refItem = $listItem->getRefItem() ) === null ) { |
|
385 | + if (($refItem = $listItem->getRefItem()) === null) { |
|
386 | 386 | continue; |
387 | 387 | } |
388 | 388 | |
389 | - if( $copy === false ) |
|
389 | + if ($copy === false) |
|
390 | 390 | { |
391 | 391 | $code = $refItem->getCode(); |
392 | 392 | $data[$code]['product.lists.id'] = $listid; |
@@ -401,11 +401,11 @@ discard block |
||
401 | 401 | |
402 | 402 | $data[$code]['product.label'] = $refItem->getLabel(); |
403 | 403 | |
404 | - if( isset( $products[$refItem->getId()] ) ) |
|
404 | + if (isset($products[$refItem->getId()])) |
|
405 | 405 | { |
406 | - $attributes = $products[$refItem->getId()]->getRefItems( 'attribute', null, 'variant' ); |
|
406 | + $attributes = $products[$refItem->getId()]->getRefItems('attribute', null, 'variant'); |
|
407 | 407 | |
408 | - foreach( $attributes as $attrid => $attrItem ) |
|
408 | + foreach ($attributes as $attrid => $attrItem) |
|
409 | 409 | { |
410 | 410 | $data[$code]['attr'][$attrid]['ref'] = $code; |
411 | 411 | $data[$code]['attr'][$attrid]['label'] = $attrItem->getLabel(); |
@@ -423,28 +423,28 @@ discard block |
||
423 | 423 | * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters |
424 | 424 | * @return array Multi-dimensional associative array |
425 | 425 | */ |
426 | - protected function getDataParams( \Aimeos\MW\View\Iface $view ) |
|
426 | + protected function getDataParams(\Aimeos\MW\View\Iface $view) |
|
427 | 427 | { |
428 | 428 | $data = array(); |
429 | 429 | |
430 | - foreach( (array) $view->param( 'selection/product.code', array() ) as $pos => $code ) |
|
430 | + foreach ((array) $view->param('selection/product.code', array()) as $pos => $code) |
|
431 | 431 | { |
432 | - if( !empty( $code ) ) |
|
432 | + if (!empty($code)) |
|
433 | 433 | { |
434 | - $data[$code]['product.lists.id'] = $view->param( 'selection/product.lists.id/' . $pos ); |
|
435 | - $data[$code]['product.id'] = $view->param( 'selection/product.id/' . $pos ); |
|
436 | - $data[$code]['product.label'] = $view->param( 'selection/product.label/' . $pos ); |
|
434 | + $data[$code]['product.lists.id'] = $view->param('selection/product.lists.id/' . $pos); |
|
435 | + $data[$code]['product.id'] = $view->param('selection/product.id/' . $pos); |
|
436 | + $data[$code]['product.label'] = $view->param('selection/product.label/' . $pos); |
|
437 | 437 | } |
438 | 438 | } |
439 | 439 | |
440 | - foreach( (array) $view->param( 'selection/attr/ref', array() ) as $pos => $code ) |
|
440 | + foreach ((array) $view->param('selection/attr/ref', array()) as $pos => $code) |
|
441 | 441 | { |
442 | - if( !empty( $code ) ) |
|
442 | + if (!empty($code)) |
|
443 | 443 | { |
444 | - $id = $view->param( 'selection/attr/id/' . $pos ); |
|
444 | + $id = $view->param('selection/attr/id/' . $pos); |
|
445 | 445 | |
446 | 446 | $data[$code]['attr'][$id]['ref'] = $code; |
447 | - $data[$code]['attr'][$id]['label'] = $view->param( 'selection/attr/label/' . $pos ); |
|
447 | + $data[$code]['attr'][$id]['label'] = $view->param('selection/attr/label/' . $pos); |
|
448 | 448 | } |
449 | 449 | } |
450 | 450 | |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | */ |
460 | 460 | protected function getSubClientNames() |
461 | 461 | { |
462 | - return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames ); |
|
462 | + return $this->getContext()->getConfig()->get($this->subPartPath, $this->subPartNames); |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | |
@@ -469,15 +469,15 @@ discard block |
||
469 | 469 | * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters |
470 | 470 | * @param boolean $copy True if items should be copied |
471 | 471 | */ |
472 | - protected function setData( \Aimeos\MW\View\Iface $view, $copy = false ) |
|
472 | + protected function setData(\Aimeos\MW\View\Iface $view, $copy = false) |
|
473 | 473 | { |
474 | - $data = $this->getDataParams( $view ); |
|
474 | + $data = $this->getDataParams($view); |
|
475 | 475 | |
476 | - if( empty( $data ) ) { |
|
477 | - $data = $this->getDataExisting( $view, $copy ); |
|
476 | + if (empty($data)) { |
|
477 | + $data = $this->getDataExisting($view, $copy); |
|
478 | 478 | } |
479 | 479 | |
480 | - if( empty( $data ) ) { // show at least one block |
|
480 | + if (empty($data)) { // show at least one block |
|
481 | 481 | $data['']['product.lists.id'] = ''; |
482 | 482 | } |
483 | 483 | |
@@ -490,39 +490,39 @@ discard block |
||
490 | 490 | * |
491 | 491 | * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters |
492 | 492 | */ |
493 | - protected function updateItems( \Aimeos\MW\View\Iface $view ) |
|
493 | + protected function updateItems(\Aimeos\MW\View\Iface $view) |
|
494 | 494 | { |
495 | - if( $view->item->getType() !== 'select' ) { |
|
495 | + if ($view->item->getType() !== 'select') { |
|
496 | 496 | return; |
497 | 497 | } |
498 | 498 | |
499 | 499 | $id = $view->item->getId(); |
500 | 500 | $context = $this->getContext(); |
501 | - $data = $this->getDataParams( $view ); |
|
501 | + $data = $this->getDataParams($view); |
|
502 | 502 | |
503 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
504 | - $listManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' ); |
|
503 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
504 | + $listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); |
|
505 | 505 | |
506 | - $product = $manager->getItem( $id, array( 'product' ) ); |
|
507 | - $listItems = $product->getListItems( 'product', 'default' ); |
|
508 | - $refItems = $product->getRefItems( 'product', null, 'default' ); |
|
506 | + $product = $manager->getItem($id, array('product')); |
|
507 | + $listItems = $product->getListItems('product', 'default'); |
|
508 | + $refItems = $product->getRefItems('product', null, 'default'); |
|
509 | 509 | |
510 | - $products = $this->getProductItems( array_keys( $data ), array_keys( $refItems ) ); |
|
511 | - $listIds = (array) $view->param( 'selection/product.lists.id', array() ); |
|
510 | + $products = $this->getProductItems(array_keys($data), array_keys($refItems)); |
|
511 | + $listIds = (array) $view->param('selection/product.lists.id', array()); |
|
512 | 512 | |
513 | - $listItem = $this->createListItem( $id ); |
|
513 | + $listItem = $this->createListItem($id); |
|
514 | 514 | $prodItem = $this->createItem(); |
515 | 515 | |
516 | 516 | |
517 | - foreach( $listIds as $idx => $listid ) |
|
517 | + foreach ($listIds as $idx => $listid) |
|
518 | 518 | { |
519 | - if( !isset( $listItems[$listid] ) ) |
|
519 | + if (!isset($listItems[$listid])) |
|
520 | 520 | { |
521 | 521 | $litem = $listItem; |
522 | - $litem->setId( null ); |
|
522 | + $litem->setId(null); |
|
523 | 523 | |
524 | 524 | $item = $prodItem; |
525 | - $item->setId( null ); |
|
525 | + $item->setId(null); |
|
526 | 526 | } |
527 | 527 | else |
528 | 528 | { |
@@ -530,26 +530,26 @@ discard block |
||
530 | 530 | $item = $litem->getRefItem(); |
531 | 531 | } |
532 | 532 | |
533 | - if( ( $code = $view->param( 'selection/product.code/' . $idx ) ) === '' ) { |
|
533 | + if (($code = $view->param('selection/product.code/' . $idx)) === '') { |
|
534 | 534 | continue; |
535 | 535 | } |
536 | 536 | |
537 | - $item->setCode( $code ); |
|
538 | - $item->setLabel( $view->param( 'selection/product.label/' . $idx ) ); |
|
537 | + $item->setCode($code); |
|
538 | + $item->setLabel($view->param('selection/product.label/' . $idx)); |
|
539 | 539 | |
540 | - $manager->saveItem( $item ); |
|
540 | + $manager->saveItem($item); |
|
541 | 541 | |
542 | - $litem->setPosition( $idx ); |
|
543 | - $litem->setRefId( $item->getId() ); |
|
542 | + $litem->setPosition($idx); |
|
543 | + $litem->setRefId($item->getId()); |
|
544 | 544 | |
545 | - $listManager->saveItem( $litem, false ); |
|
545 | + $listManager->saveItem($litem, false); |
|
546 | 546 | |
547 | - $variant = ( isset( $products[$item->getId()] ) ? $products[$item->getId()] : $item ); |
|
548 | - $attr = ( isset( $data[$code]['attr'] ) ? (array) $data[$code]['attr'] : array() ); |
|
547 | + $variant = (isset($products[$item->getId()]) ? $products[$item->getId()] : $item); |
|
548 | + $attr = (isset($data[$code]['attr']) ? (array) $data[$code]['attr'] : array()); |
|
549 | 549 | |
550 | - $manager->updateListItems( $variant, $attr, 'attribute', 'variant' ); |
|
550 | + $manager->updateListItems($variant, $attr, 'attribute', 'variant'); |
|
551 | 551 | } |
552 | 552 | |
553 | - $this->cleanupItems( $listItems, $listIds ); |
|
553 | + $this->cleanupItems($listItems, $listIds); |
|
554 | 554 | } |
555 | 555 | } |
556 | 556 | \ No newline at end of file |
@@ -151,14 +151,12 @@ discard block |
||
151 | 151 | |
152 | 152 | $manager->commit(); |
153 | 153 | return; |
154 | - } |
|
155 | - catch( \Aimeos\MShop\Exception $e ) |
|
154 | + } catch( \Aimeos\MShop\Exception $e ) |
|
156 | 155 | { |
157 | 156 | $error = array( 'product-item-selection' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
158 | 157 | $view->errors = $view->get( 'errors', array() ) + $error; |
159 | 158 | $manager->rollback(); |
160 | - } |
|
161 | - catch( \Exception $e ) |
|
159 | + } catch( \Exception $e ) |
|
162 | 160 | { |
163 | 161 | $context->getLogger()->log( $e->getMessage() . ' - ' . $e->getTraceAsString() ); |
164 | 162 | $error = array( 'product-item-selection' => $e->getMessage() ); |
@@ -391,8 +389,7 @@ discard block |
||
391 | 389 | $code = $refItem->getCode(); |
392 | 390 | $data[$code]['product.lists.id'] = $listid; |
393 | 391 | $data[$code]['product.id'] = $listItem->getRefId(); |
394 | - } |
|
395 | - else |
|
392 | + } else |
|
396 | 393 | { |
397 | 394 | $code = $refItem->getCode() . '_copy'; |
398 | 395 | $data[$code]['product.lists.id'] = ''; |
@@ -523,8 +520,7 @@ discard block |
||
523 | 520 | |
524 | 521 | $item = $prodItem; |
525 | 522 | $item->setId( null ); |
526 | - } |
|
527 | - else |
|
523 | + } else |
|
528 | 524 | { |
529 | 525 | $litem = $listItems[$listid]; |
530 | 526 | $item = $litem->getRefItem(); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * Copies a resource |
65 | 65 | * |
66 | - * @return string|null admin output to display or null for redirecting to the list |
|
66 | + * @return string admin output to display or null for redirecting to the list |
|
67 | 67 | */ |
68 | 68 | public function copy() |
69 | 69 | { |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | /** |
87 | 87 | * Creates a new resource |
88 | 88 | * |
89 | - * @return string|null admin output to display or null for redirecting to the list |
|
89 | + * @return string admin output to display or null for redirecting to the list |
|
90 | 90 | */ |
91 | 91 | public function create() |
92 | 92 | { |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | /** |
110 | 110 | * Returns a single resource |
111 | 111 | * |
112 | - * @return string|null admin output to display or null for redirecting to the list |
|
112 | + * @return string admin output to display or null for redirecting to the list |
|
113 | 113 | */ |
114 | 114 | public function get() |
115 | 115 | { |