|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2017 |
|
6
|
|
|
* @package Controller |
|
7
|
|
|
* @subpackage Common |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
namespace Aimeos\Controller\Common\Order\Export\Csv\Processor\Product; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Product processor for order CSV exports |
|
16
|
|
|
* |
|
17
|
|
|
* @package Controller |
|
18
|
|
|
* @subpackage Common |
|
19
|
|
|
*/ |
|
20
|
|
|
class Standard |
|
21
|
|
|
extends \Aimeos\Controller\Common\Order\Export\Csv\Processor\Base |
|
|
|
|
|
|
22
|
|
|
implements \Aimeos\Controller\Common\Order\Export\Csv\Processor\Iface |
|
|
|
|
|
|
23
|
|
|
{ |
|
24
|
|
|
/** controller/common/order/export/csv/processor/product/name |
|
25
|
|
|
* Name of the product processor implementation |
|
26
|
|
|
* |
|
27
|
|
|
* Use "Myname" if your class is named "\Aimeos\Controller\Common\Order\Export\Csv\Processor\Product\Myname". |
|
28
|
|
|
* The name is case-sensitive and you should avoid camel case names like "MyName". |
|
29
|
|
|
* |
|
30
|
|
|
* @param string Last part of the processor class name |
|
31
|
|
|
* @since 2017.08 |
|
32
|
|
|
* @category Developer |
|
33
|
|
|
*/ |
|
34
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Returns the order related data |
|
38
|
|
|
* |
|
39
|
|
|
* @param \Aimeos\MShop\Order\Item\Iface $invoice Invoice item |
|
40
|
|
|
* @param \Aimeos\MShop\Order\Item\Base\Iface $order Full order with associated items |
|
41
|
|
|
* @return array Two dimensional associative list of order data representing the lines in CSV |
|
42
|
|
|
*/ |
|
43
|
|
|
public function process( \Aimeos\MShop\Order\Item\Iface $invoice, \Aimeos\MShop\Order\Item\Base\Iface $order ) |
|
44
|
|
|
{ |
|
45
|
|
|
$result = []; |
|
46
|
|
|
|
|
47
|
|
|
foreach( $order->getProducts() as $item ) |
|
48
|
|
|
{ |
|
49
|
|
|
$data = []; |
|
50
|
|
|
$list = $item->toArray(); |
|
51
|
|
|
|
|
52
|
|
|
foreach( $item->getAttributes() as $attrItem ) |
|
53
|
|
|
{ |
|
54
|
|
|
foreach( $attrItem->toArray() as $key => $value ) |
|
55
|
|
|
{ |
|
56
|
|
|
if( isset( $list[$key] ) ) { |
|
57
|
|
|
$list[$key] .= "\n" . $value; |
|
58
|
|
|
} else { |
|
59
|
|
|
$list[$key] = $value; |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
foreach( $this->getMapping() as $pos => $key ) |
|
65
|
|
|
{ |
|
66
|
|
|
if( array_key_exists( $key, $list ) ) { |
|
67
|
|
|
$data[$pos] = $list[$key]; |
|
68
|
|
|
} else { |
|
69
|
|
|
$data[$pos] = ''; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
ksort( $data ); |
|
74
|
|
|
$result[] = $data; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
return $result; |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|