| Total Complexity | 61 |
| Total Lines | 642 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like Standard often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Standard, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 22 | class Standard |
||
| 23 | extends \Aimeos\Admin\JQAdm\Common\Admin\Factory\Base |
||
| 24 | implements \Aimeos\Admin\JQAdm\Common\Admin\Factory\Iface |
||
| 25 | { |
||
| 26 | /** |
||
| 27 | * Copies a resource |
||
| 28 | * |
||
| 29 | * @return string HTML output |
||
| 30 | */ |
||
| 31 | public function copy() |
||
| 32 | { |
||
| 33 | $view = $this->getView(); |
||
| 34 | $context = $this->getContext(); |
||
| 35 | |||
| 36 | try |
||
| 37 | { |
||
| 38 | if( ( $id = $view->param( 'id' ) ) === null ) { |
||
| 39 | throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Required parameter "%1$s" is missing', 'id' ) ); |
||
| 40 | } |
||
| 41 | |||
| 42 | $manager = \Aimeos\MShop::create( $context, 'order/base' ); |
||
| 43 | $view->item = $manager->load( $id ); |
||
|
1 ignored issue
–
show
|
|||
| 44 | |||
| 45 | $view->itemData = $this->toArray( $view->item, true ); |
||
| 46 | $view->itemSubparts = $this->getSubClientNames(); |
||
| 47 | $view->itemBody = ''; |
||
| 48 | |||
| 49 | foreach( $this->getSubClients() as $idx => $client ) |
||
| 50 | { |
||
| 51 | $view->tabindex = ++$idx + 1; |
||
| 52 | $view->itemBody .= $client->copy(); |
||
| 53 | } |
||
| 54 | } |
||
| 55 | catch( \Aimeos\MShop\Exception $e ) |
||
| 56 | { |
||
| 57 | $error = array( 'order-item' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
||
| 58 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 59 | $this->logException( $e ); |
||
| 60 | } |
||
| 61 | catch( \Exception $e ) |
||
| 62 | { |
||
| 63 | $error = array( 'order-item' => $e->getMessage() . ', ' . $e->getFile() . ':' . $e->getLine() ); |
||
| 64 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 65 | $this->logException( $e ); |
||
| 66 | } |
||
| 67 | |||
| 68 | return $this->render( $view ); |
||
| 69 | } |
||
| 70 | |||
| 71 | |||
| 72 | /** |
||
| 73 | * Creates a new resource |
||
| 74 | * |
||
| 75 | * @return string HTML output |
||
| 76 | */ |
||
| 77 | public function create() |
||
| 78 | { |
||
| 79 | $view = $this->getView(); |
||
| 80 | $context = $this->getContext(); |
||
| 81 | |||
| 82 | try |
||
| 83 | { |
||
| 84 | $data = $view->param( 'item', [] ); |
||
| 85 | |||
| 86 | if( !isset( $view->item ) ) { |
||
| 87 | $view->item = \Aimeos\MShop::create( $context, 'order/base' )->createItem(); |
||
| 88 | } |
||
| 89 | |||
| 90 | $data['order.siteid'] = $view->item->getSiteId(); |
||
| 91 | |||
| 92 | $view->itemSubparts = $this->getSubClientNames(); |
||
| 93 | $view->itemData = $data; |
||
| 94 | $view->itemBody = ''; |
||
| 95 | |||
| 96 | foreach( $this->getSubClients() as $idx => $client ) |
||
| 97 | { |
||
| 98 | $view->tabindex = ++$idx + 1; |
||
| 99 | $view->itemBody .= $client->create(); |
||
| 100 | } |
||
| 101 | } |
||
| 102 | catch( \Aimeos\MShop\Exception $e ) |
||
| 103 | { |
||
| 104 | $error = array( 'order-item' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
||
| 105 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 106 | $this->logException( $e ); |
||
| 107 | } |
||
| 108 | catch( \Exception $e ) |
||
| 109 | { |
||
| 110 | $error = array( 'order-item' => $e->getMessage() . ', ' . $e->getFile() . ':' . $e->getLine() ); |
||
| 111 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 112 | $this->logException( $e ); |
||
| 113 | } |
||
| 114 | |||
| 115 | return $this->render( $view ); |
||
| 116 | } |
||
| 117 | |||
| 118 | |||
| 119 | /** |
||
| 120 | * Exports a resource |
||
| 121 | * |
||
| 122 | * @return string Admin output to display |
||
| 123 | */ |
||
| 124 | public function export() |
||
| 125 | { |
||
| 126 | $view = $this->getView(); |
||
| 127 | $context = $this->getContext(); |
||
| 128 | |||
| 129 | try |
||
| 130 | { |
||
| 131 | $params = $this->storeSearchParams( $view->param(), 'order' ); |
||
| 132 | $msg = ['sitecode' => $context->getLocale()->getSite()->getCode()]; |
||
| 133 | |||
| 134 | if( isset( $params['filter'] ) ) { |
||
| 135 | $msg['filter'] = $this->getCriteriaConditions( $params['filter'] ); |
||
| 136 | } |
||
| 137 | |||
| 138 | if( isset( $params['sort'] ) ) { |
||
| 139 | $msg['sort'] = $this->getCriteriaSortations( $params['sort'] ); |
||
| 140 | } |
||
| 141 | |||
| 142 | $mq = $context->getMessageQueueManager()->get( 'mq-admin' )->getQueue( 'order-export' ); |
||
| 143 | $mq->add( json_encode( $msg ) ); |
||
| 144 | |||
| 145 | $msg = $context->getI18n()->dt( 'admin', 'Your export will be available in a few minutes for download' ); |
||
| 146 | $view->info = $view->get( 'info', [] ) + ['order-item' => $msg]; |
||
| 147 | } |
||
| 148 | catch( \Aimeos\MShop\Exception $e ) |
||
| 149 | { |
||
| 150 | $error = array( 'order-item' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
||
| 151 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 152 | $this->logException( $e ); |
||
| 153 | } |
||
| 154 | catch( \Exception $e ) |
||
| 155 | { |
||
| 156 | $error = array( 'order-item' => $e->getMessage() . ', ' . $e->getFile() . ':' . $e->getLine() ); |
||
| 157 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 158 | $this->logException( $e ); |
||
| 159 | } |
||
| 160 | |||
| 161 | return $this->search(); |
||
| 162 | } |
||
| 163 | |||
| 164 | |||
| 165 | /** |
||
| 166 | * Returns a single resource |
||
| 167 | * |
||
| 168 | * @return string HTML output |
||
| 169 | */ |
||
| 170 | public function get() |
||
| 171 | { |
||
| 172 | $view = $this->getView(); |
||
| 173 | $context = $this->getContext(); |
||
| 174 | |||
| 175 | try |
||
| 176 | { |
||
| 177 | if( ( $id = $view->param( 'id' ) ) === null ) { |
||
| 178 | throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Required parameter "%1$s" is missing', 'id' ) ); |
||
| 179 | } |
||
| 180 | |||
| 181 | $manager = \Aimeos\MShop::create( $context, 'order/base' ); |
||
| 182 | $refs = ['order/base/address', 'order/base/coupon', 'order/base/product', 'order/base/service']; |
||
| 183 | |||
| 184 | $view->item = $manager->getItem( $id, $refs ); |
||
| 185 | $view->itemSubparts = $this->getSubClientNames(); |
||
| 186 | $view->itemData = $this->toArray( $view->item ); |
||
| 187 | $view->itemBody = ''; |
||
| 188 | |||
| 189 | foreach( $this->getSubClients() as $idx => $client ) |
||
| 190 | { |
||
| 191 | $view->tabindex = ++$idx + 1; |
||
| 192 | $view->itemBody .= $client->get(); |
||
| 193 | } |
||
| 194 | } |
||
| 195 | catch( \Aimeos\MShop\Exception $e ) |
||
| 196 | { |
||
| 197 | $error = array( 'order-item' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
||
| 198 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 199 | $this->logException( $e ); |
||
| 200 | } |
||
| 201 | catch( \Exception $e ) |
||
| 202 | { |
||
| 203 | $error = array( 'order-item' => $e->getMessage() . ', ' . $e->getFile() . ':' . $e->getLine() ); |
||
| 204 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 205 | $this->logException( $e ); |
||
| 206 | } |
||
| 207 | |||
| 208 | return $this->render( $view ); |
||
| 209 | } |
||
| 210 | |||
| 211 | |||
| 212 | /** |
||
| 213 | * Saves the data |
||
| 214 | * |
||
| 215 | * @return string HTML output |
||
| 216 | */ |
||
| 217 | public function save() |
||
| 218 | { |
||
| 219 | $view = $this->getView(); |
||
| 220 | $context = $this->getContext(); |
||
| 221 | |||
| 222 | $manager = \Aimeos\MShop::create( $context, 'order/base' ); |
||
| 223 | $manager->begin(); |
||
| 224 | |||
| 225 | try |
||
| 226 | { |
||
| 227 | $item = $this->fromArray( $view->param( 'item', [] ) ); |
||
| 228 | $view->item = $item->getId() ? $item : $manager->store( clone $item ); |
||
|
1 ignored issue
–
show
|
|||
| 229 | $view->itemBody = ''; |
||
| 230 | |||
| 231 | foreach( $this->getSubClients() as $client ) { |
||
| 232 | $view->itemBody .= $client->save(); |
||
| 233 | } |
||
| 234 | |||
| 235 | $manager->store( clone $view->item ); |
||
| 236 | $manager->commit(); |
||
| 237 | |||
| 238 | $this->nextAction( $view, $view->param( 'next' ), 'order', $view->item->getId(), 'save' ); |
||
| 239 | return; |
||
| 240 | } |
||
| 241 | catch( \Aimeos\Admin\JQAdm\Exception $e ) |
||
| 242 | { |
||
| 243 | // fall through to create |
||
| 244 | } |
||
| 245 | catch( \Aimeos\MShop\Exception $e ) |
||
| 246 | { |
||
| 247 | $error = array( 'order-item' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
||
| 248 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 249 | $this->logException( $e ); |
||
| 250 | } |
||
| 251 | catch( \Exception $e ) |
||
| 252 | { |
||
| 253 | $error = array( 'order-item' => $e->getMessage() . ', ' . $e->getFile() . ':' . $e->getLine() ); |
||
| 254 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 255 | $this->logException( $e ); |
||
| 256 | } |
||
| 257 | |||
| 258 | $manager->rollback(); |
||
| 259 | |||
| 260 | return $this->get(); |
||
| 261 | } |
||
| 262 | |||
| 263 | |||
| 264 | /** |
||
| 265 | * Returns a list of resource according to the conditions |
||
| 266 | * |
||
| 267 | * @return string HTML output |
||
| 268 | */ |
||
| 269 | public function search() |
||
| 270 | { |
||
| 271 | $view = $this->getView(); |
||
| 272 | $context = $this->getContext(); |
||
| 273 | |||
| 274 | try |
||
| 275 | { |
||
| 276 | $total = 0; |
||
| 277 | $params = $this->storeSearchParams( $view->param(), 'order' ); |
||
| 278 | $manager = \Aimeos\MShop::create( $context, 'order' ); |
||
| 279 | |||
| 280 | $search = $manager->createSearch(); |
||
| 281 | $search->setSortations( [$search->sort( '-', 'order.id' )] ); |
||
| 282 | $search = $this->initCriteria( $search, $params ); |
||
| 283 | |||
| 284 | $view->items = $manager->searchItems( $search, [], $total ); |
||
| 285 | $view->baseItems = $this->getOrderBaseItems( $view->items ); |
||
| 286 | $view->filterAttributes = $manager->getSearchAttributes( true ); |
||
| 287 | $view->filterOperators = $search->getOperators(); |
||
| 288 | $view->total = $total; |
||
| 289 | $view->itemBody = ''; |
||
| 290 | |||
| 291 | foreach( $this->getSubClients() as $client ) { |
||
| 292 | $view->itemBody .= $client->search(); |
||
| 293 | } |
||
| 294 | } |
||
| 295 | catch( \Aimeos\MShop\Exception $e ) |
||
| 296 | { |
||
| 297 | $error = array( 'order-item' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
||
| 298 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 299 | $this->logException( $e ); |
||
| 300 | } |
||
| 301 | catch( \Exception $e ) |
||
| 302 | { |
||
| 303 | $error = array( 'order-item' => $e->getMessage() . ', ' . $e->getFile() . ':' . $e->getLine() ); |
||
| 304 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 305 | $this->logException( $e ); |
||
| 306 | } |
||
| 307 | |||
| 308 | /** admin/jqadm/order/template-list |
||
| 309 | * Relative path to the HTML body template for the order list. |
||
| 310 | * |
||
| 311 | * The template file contains the HTML code and processing instructions |
||
| 312 | * to generate the result shown in the body of the frontend. The |
||
| 313 | * configuration string is the path to the template file relative |
||
| 314 | * to the templates directory (usually in admin/jqadm/templates). |
||
| 315 | * |
||
| 316 | * You can overwrite the template file configuration in extensions and |
||
| 317 | * provide alternative templates. These alternative templates should be |
||
| 318 | * named like the default one but with the string "default" replaced by |
||
| 319 | * an unique name. You may use the name of your project for this. If |
||
| 320 | * you've implemented an alternative client class as well, "default" |
||
| 321 | * should be replaced by the name of the new class. |
||
| 322 | * |
||
| 323 | * @param string Relative path to the template creating the HTML code |
||
| 324 | * @since 2016.04 |
||
| 325 | * @category Developer |
||
| 326 | */ |
||
| 327 | $tplconf = 'admin/jqadm/order/template-list'; |
||
| 328 | $default = 'order/list-standard'; |
||
| 329 | |||
| 330 | return $view->render( $view->config( $tplconf, $default ) ); |
||
| 331 | } |
||
| 332 | |||
| 333 | |||
| 334 | /** |
||
| 335 | * Returns the sub-client given by its name. |
||
| 336 | * |
||
| 337 | * @param string $type Name of the client type |
||
| 338 | * @param string|null $name Name of the sub-client (Default if null) |
||
| 339 | * @return \Aimeos\Admin\JQAdm\Iface Sub-client object |
||
| 340 | */ |
||
| 341 | public function getSubClient( $type, $name = null ) |
||
| 417 | } |
||
| 418 | |||
| 419 | |||
| 420 | /** |
||
| 421 | * Returns the base order items (baskets) for the given order items (invoices) |
||
| 422 | * |
||
| 423 | * @param \Aimeos\MShop\Order\Item\Iface[] $orderItems List of order items |
||
| 424 | * @param \Aimeos\MShop\Order\Item\Base\Iface[] List of order base items |
||
| 425 | */ |
||
| 426 | protected function getOrderBaseItems( array $orderItems ) |
||
| 427 | { |
||
| 428 | $baseIds = []; |
||
| 429 | foreach( $orderItems as $item ) { |
||
| 430 | $baseIds[] = $item->getBaseId(); |
||
| 431 | } |
||
| 432 | |||
| 433 | $manager = \Aimeos\MShop::create( $this->getContext(), 'order/base' ); |
||
| 434 | |||
| 435 | $search = $manager->createSearch()->setSlice( 0, count( $baseIds ) ); |
||
| 436 | $search->setConditions( $search->compare( '==', 'order.base.id', $baseIds ) ); |
||
| 437 | |||
| 438 | return $manager->searchItems( $search, ['order/base/address', 'order/base/service'] ); |
||
| 439 | } |
||
| 440 | |||
| 441 | |||
| 442 | /** |
||
| 443 | * Returns the list of sub-client names configured for the client. |
||
| 444 | * |
||
| 445 | * @return array List of JQAdm client names |
||
| 446 | */ |
||
| 447 | protected function getSubClientNames() |
||
| 448 | { |
||
| 449 | /** admin/jqadm/order/standard/subparts |
||
| 450 | * List of JQAdm sub-clients rendered within the order section |
||
| 451 | * |
||
| 452 | * The output of the frontend is composed of the code generated by the JQAdm |
||
| 453 | * clients. Each JQAdm client can consist of serveral (or none) sub-clients |
||
| 454 | * that are responsible for rendering certain sub-parts of the output. The |
||
| 455 | * sub-clients can contain JQAdm clients themselves and therefore a |
||
| 456 | * hierarchical tree of JQAdm clients is composed. Each JQAdm client creates |
||
| 457 | * the output that is placed inside the container of its parent. |
||
| 458 | * |
||
| 459 | * At first, always the JQAdm code generated by the parent is printed, then |
||
| 460 | * the JQAdm code of its sub-clients. The order of the JQAdm sub-clients |
||
| 461 | * determines the order of the output of these sub-clients inside the parent |
||
| 462 | * container. If the configured list of clients is |
||
| 463 | * |
||
| 464 | * array( "subclient1", "subclient2" ) |
||
| 465 | * |
||
| 466 | * you can easily change the order of the output by reordering the subparts: |
||
| 467 | * |
||
| 468 | * admin/jqadm/<clients>/subparts = array( "subclient1", "subclient2" ) |
||
| 469 | * |
||
| 470 | * You can also remove one or more parts if they shouldn't be rendered: |
||
| 471 | * |
||
| 472 | * admin/jqadm/<clients>/subparts = array( "subclient1" ) |
||
| 473 | * |
||
| 474 | * As the clients only generates structural JQAdm, the layout defined via CSS |
||
| 475 | * should support adding, removing or reordering content by a fluid like |
||
| 476 | * design. |
||
| 477 | * |
||
| 478 | * @param array List of sub-client names |
||
| 479 | * @since 2016.01 |
||
| 480 | * @category Developer |
||
| 481 | */ |
||
| 482 | return $this->getContext()->getConfig()->get( 'admin/jqadm/order/standard/subparts', [] ); |
||
| 483 | } |
||
| 484 | |||
| 485 | |||
| 486 | /** |
||
| 487 | * Creates new and updates existing items using the data array |
||
| 488 | * |
||
| 489 | * @param string[] Data array |
||
| 490 | * @return \Aimeos\MShop\Order\Item\Iface New order item object |
||
| 491 | */ |
||
| 492 | protected function fromArray( array $data ) |
||
| 493 | { |
||
| 494 | $manager = \Aimeos\MShop::create( $this->getContext(), 'order/base' ); |
||
| 495 | $attrManager = \Aimeos\MShop::create( $this->getContext(), 'order/base/service/attribute' ); |
||
| 496 | |||
| 497 | if( isset( $data['order.base.id'] ) ) { |
||
| 498 | $basket = $manager->load( $data['order.base.id'] ); |
||
| 499 | } else { |
||
| 500 | $basket = $manager->createItem(); |
||
| 501 | } |
||
| 502 | |||
| 503 | $basket->fromArray( $data ); |
||
| 504 | |||
| 505 | foreach( $basket->getProducts() as $pos => $product ) |
||
| 506 | { |
||
| 507 | if( isset( $data['product'][$pos]['order.base.product.status'] ) ) { |
||
| 508 | $product->setStatus( $data['product'][$pos]['order.base.product.status'] ); |
||
| 509 | } |
||
| 510 | } |
||
| 511 | |||
| 512 | foreach( $basket->getAddresses() as $type => $address ) |
||
| 513 | { |
||
| 514 | if( isset( $data['address'][$type] ) ) { |
||
| 515 | $list = (array) $data['address'][$type]; |
||
| 516 | $basket->setAddress( $address->fromArray( $list ), $type ); |
||
| 517 | } else { |
||
| 518 | $basket->deleteAddress( $type ); |
||
| 519 | } |
||
| 520 | } |
||
| 521 | |||
| 522 | foreach( $basket->getServices() as $type => $services ) |
||
| 523 | { |
||
| 524 | foreach( $services as $serviceId => $service ) |
||
| 525 | { |
||
| 526 | $list = []; |
||
| 527 | $attrItems = $service->getAttributeItems(); |
||
| 528 | |||
| 529 | if( isset( $data['service'][$type][$serviceId] ) ) |
||
| 530 | { |
||
| 531 | foreach( (array) $data['service'][$type][$serviceId] as $key => $pair ) |
||
| 532 | { |
||
| 533 | foreach( $pair as $pos => $value ) { |
||
| 534 | $list[$pos][$key] = $value; |
||
| 535 | } |
||
| 536 | } |
||
| 537 | |||
| 538 | foreach( $list as $array ) |
||
| 539 | { |
||
| 540 | if( isset( $attrItems[$array['order.base.service.attribute.id']] ) ) |
||
| 541 | { |
||
| 542 | $attrItem = $attrItems[$array['order.base.service.attribute.id']]; |
||
| 543 | unset( $attrItems[$array['order.base.service.attribute.id']] ); |
||
| 544 | } |
||
| 545 | else |
||
| 546 | { |
||
| 547 | $attrItem = $attrManager->createItem(); |
||
| 548 | } |
||
| 549 | |||
| 550 | $attrItem->fromArray( $array ); |
||
| 551 | $attrItem->setParentId( $service->getId() ); |
||
| 552 | |||
| 553 | $item = $attrManager->saveItem( $attrItem ); |
||
| 554 | } |
||
| 555 | } |
||
| 556 | |||
| 557 | $attrManager->deleteItems( array_keys( $attrItems ) ); |
||
| 558 | } |
||
| 559 | } |
||
| 560 | |||
| 561 | return $basket; |
||
| 562 | } |
||
| 563 | |||
| 564 | |||
| 565 | /** |
||
| 566 | * Constructs the data array for the view from the given item |
||
| 567 | * |
||
| 568 | * @param \Aimeos\MShop\Order\Item\Base\Iface $item Order base item object |
||
| 569 | * @return string[] Multi-dimensional associative list of item data |
||
| 570 | */ |
||
| 571 | protected function toArray( \Aimeos\MShop\Order\Item\Base\Iface $item, $copy = false ) |
||
| 572 | { |
||
| 573 | $siteId = $this->getContext()->getLocale()->getSiteId(); |
||
| 574 | $data = $item->toArray( true ); |
||
| 575 | |||
| 576 | if( $item->getCustomerId() != '' ) |
||
| 577 | { |
||
| 578 | $manager = \Aimeos\MShop::create( $this->getContext(), 'customer' ); |
||
| 579 | |||
| 580 | try { |
||
| 581 | $data += $manager->getItem( $item->getCustomerId() )->toArray(); |
||
| 582 | } catch( \Exception $e ) {}; |
||
| 583 | } |
||
| 584 | |||
| 585 | |||
| 586 | if( $copy === true ) |
||
| 587 | { |
||
| 588 | $data['order.base.siteid'] = $siteId; |
||
| 589 | $data['order.base.id'] = ''; |
||
| 590 | } |
||
| 591 | |||
| 592 | foreach( $item->getAddresses() as $type => $addrItem ) |
||
| 593 | { |
||
| 594 | $list = $addrItem->toArray( true ); |
||
| 595 | |||
| 596 | foreach( $list as $key => $value ) { |
||
| 597 | $data['address'][$type][$key] = $value; |
||
| 598 | } |
||
| 599 | |||
| 600 | if( $copy === true ) |
||
| 601 | { |
||
| 602 | $data['address'][$type]['order.base.address.siteid'] = $siteId; |
||
| 603 | $data['address'][$type]['order.base.address.id'] = ''; |
||
| 604 | } |
||
| 605 | } |
||
| 606 | |||
| 607 | if( $copy !== true ) |
||
| 608 | { |
||
| 609 | foreach( $item->getServices() as $type => $services ) |
||
| 610 | { |
||
| 611 | foreach( $services as $serviceItem ) |
||
| 612 | { |
||
| 613 | $serviceId = $serviceItem->getServiceId(); |
||
| 614 | |||
| 615 | foreach( $serviceItem->getAttributeItems() as $attrItem ) |
||
| 616 | { |
||
| 617 | foreach( $attrItem->toArray( true ) as $key => $value ) { |
||
| 618 | $data['service'][$type][$serviceId][$key][] = $value; |
||
| 619 | } |
||
| 620 | } |
||
| 621 | } |
||
| 622 | } |
||
| 623 | } |
||
| 624 | |||
| 625 | foreach( $item->getProducts() as $pos => $productItem ) { |
||
| 626 | $data['product'][$pos]['order.base.product.status'] = $productItem->getStatus(); |
||
| 627 | } |
||
| 628 | |||
| 629 | return $data; |
||
| 630 | } |
||
| 631 | |||
| 632 | |||
| 633 | /** |
||
| 634 | * Returns the rendered template including the view data |
||
| 635 | * |
||
| 636 | * @param \Aimeos\MW\View\Iface $view View object with data assigned |
||
| 637 | * @return string HTML output |
||
| 638 | */ |
||
| 639 | protected function render( \Aimeos\MW\View\Iface $view ) |
||
| 664 | } |
||
| 665 | } |
||
| 666 |