1 | <?php |
||||||
2 | |||||||
3 | /** |
||||||
4 | * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
||||||
5 | * @copyright Metaways Infosystems GmbH, 2014 |
||||||
6 | * @copyright Aimeos (aimeos.org), 2015-2018 |
||||||
7 | */ |
||||||
8 | |||||||
9 | |||||||
10 | namespace Aimeos\MW\Setup\Task; |
||||||
11 | |||||||
12 | |||||||
13 | /** |
||||||
14 | * Adds demo records to customer tables. |
||||||
15 | */ |
||||||
16 | class DemoAddCustomerData extends \Aimeos\MW\Setup\Task\MShopAddDataAbstract |
||||||
17 | { |
||||||
18 | /** |
||||||
19 | * Returns the list of task names which this task depends on. |
||||||
20 | * |
||||||
21 | * @return string[] List of task names |
||||||
22 | */ |
||||||
23 | public function getPreDependencies() |
||||||
24 | { |
||||||
25 | return array( 'MShopAddTypeDataDefault', 'MShopAddCodeDataDefault' ); |
||||||
26 | } |
||||||
27 | |||||||
28 | |||||||
29 | /** |
||||||
30 | * Returns the list of task names which depends on this task. |
||||||
31 | * |
||||||
32 | * @return array List of task names |
||||||
33 | */ |
||||||
34 | public function getPostDependencies() |
||||||
35 | { |
||||||
36 | return []; |
||||||
37 | } |
||||||
38 | |||||||
39 | |||||||
40 | /** |
||||||
41 | * Insert service data. |
||||||
42 | */ |
||||||
43 | public function migrate() |
||||||
44 | { |
||||||
45 | $this->msg( 'Processing customer demo data', 0 ); |
||||||
46 | |||||||
47 | $context = $this->getContext(); |
||||||
48 | $value = $context->getConfig()->get( 'setup/default/demo', '' ); |
||||||
49 | |||||||
50 | if( $value === '' ) |
||||||
51 | { |
||||||
52 | $this->status( 'OK' ); |
||||||
53 | return; |
||||||
54 | } |
||||||
55 | |||||||
56 | |||||||
57 | $manager = \Aimeos\MShop::create( $context, 'customer' ); |
||||||
58 | |||||||
59 | $search = $manager->createSearch(); |
||||||
60 | $search->setConditions( $search->compare( '=~', 'customer.code', 'demo-' ) ); |
||||||
61 | $services = $manager->searchItems( $search ); |
||||||
62 | |||||||
63 | $manager->deleteItems( array_keys( $services ) ); |
||||||
64 | |||||||
65 | |||||||
66 | if( $value === '1' ) |
||||||
67 | { |
||||||
68 | $ds = DIRECTORY_SEPARATOR; |
||||||
69 | $path = __DIR__ . $ds . 'data' . $ds . 'demo-customer.php'; |
||||||
70 | |||||||
71 | if( ( $data = include( $path ) ) == false ) { |
||||||
72 | throw new \Aimeos\MShop\Exception( sprintf( 'No file "%1$s" found for customer domain', $path ) ); |
||||||
73 | } |
||||||
74 | |||||||
75 | $this->saveCustomerItems( $data ); |
||||||
76 | |||||||
77 | $this->status( 'added' ); |
||||||
78 | } |
||||||
79 | else |
||||||
80 | { |
||||||
81 | $this->status( 'removed' ); |
||||||
82 | } |
||||||
83 | } |
||||||
84 | |||||||
85 | |||||||
86 | /** |
||||||
87 | * Stores the customer items |
||||||
88 | * |
||||||
89 | * @param array $data List of arrays containing the customer properties |
||||||
90 | */ |
||||||
91 | protected function saveCustomerItems( array $data ) |
||||||
92 | { |
||||||
93 | $manager = \Aimeos\MShop::create( $this->getContext(), 'customer' ); |
||||||
94 | |||||||
95 | foreach( $data as $entry ) |
||||||
96 | { |
||||||
97 | $item = $manager->createItem(); |
||||||
98 | $item->setCode( $entry['code'] ); |
||||||
99 | $item->setLabel( $entry['label'] ); |
||||||
100 | $item->setBirthday( $entry['birthday'] ); |
||||||
0 ignored issues
–
show
|
|||||||
101 | $item->setPassword( $entry['password'] ); |
||||||
0 ignored issues
–
show
The method
setPassword() does not exist on Aimeos\MShop\Attribute\Item\Iface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
102 | $item->setStatus( $entry['status'] ); |
||||||
103 | $item->setDateVerified( $entry['vtime'] ); |
||||||
0 ignored issues
–
show
The method
setDateVerified() does not exist on Aimeos\MShop\Attribute\Item\Iface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
104 | |||||||
105 | $addr = $item->getPaymentAddress(); |
||||||
0 ignored issues
–
show
The method
getPaymentAddress() does not exist on Aimeos\MShop\Attribute\Item\Iface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
106 | $addr->setTitle( $entry['title'] ); |
||||||
107 | $addr->setSalutation( $entry['salutation'] ); |
||||||
108 | $addr->setCompany( $entry['company'] ); |
||||||
109 | $addr->setVatID( $entry['vatid'] ); |
||||||
110 | $addr->setFirstname( $entry['firstname'] ); |
||||||
111 | $addr->setLastname( $entry['lastname'] ); |
||||||
112 | $addr->setAddress1( $entry['address1'] ); |
||||||
113 | $addr->setAddress2( $entry['address2'] ); |
||||||
114 | $addr->setAddress3( $entry['address3'] ); |
||||||
115 | $addr->setPostal( $entry['postal'] ); |
||||||
116 | $addr->setCity( $entry['city'] ); |
||||||
117 | $addr->setState( $entry['state'] ); |
||||||
118 | $addr->setLanguageId( $entry['langid'] ); |
||||||
119 | $addr->setCountryId( $entry['countryid'] ); |
||||||
120 | $addr->setTelephone( $entry['telephone'] ); |
||||||
121 | $addr->setEmail( $entry['email'] ); |
||||||
122 | $addr->setTelefax( $entry['telefax'] ); |
||||||
123 | $addr->setWebsite( $entry['website'] ); |
||||||
124 | |||||||
125 | $manager->saveItem( $item ); |
||||||
126 | |||||||
127 | if( isset( $entry['delivery'] ) ) { |
||||||
128 | $this->saveAddressItems( $entry['delivery'], $item->getId() ); |
||||||
129 | } |
||||||
130 | } |
||||||
131 | } |
||||||
132 | |||||||
133 | |||||||
134 | /** |
||||||
135 | * Stores the customer items |
||||||
136 | * |
||||||
137 | * @param array $data List of arrays containing the customer properties |
||||||
138 | * @param string $id Unique ID of the customer item |
||||||
139 | */ |
||||||
140 | protected function saveAddressItems( array $data, $id ) |
||||||
141 | { |
||||||
142 | $manager = \Aimeos\MShop::create( $this->getContext(), 'customer/address' ); |
||||||
143 | |||||||
144 | foreach( $data as $entry ) |
||||||
145 | { |
||||||
146 | $addr = $manager->createItem(); |
||||||
147 | $addr->setParentId( $id ); |
||||||
0 ignored issues
–
show
The method
setParentId() does not exist on Aimeos\MShop\Attribute\Item\Iface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
148 | $addr->setTitle( $entry['title'] ); |
||||||
0 ignored issues
–
show
The method
setTitle() does not exist on Aimeos\MShop\Attribute\Item\Iface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
149 | $addr->setSalutation( $entry['salutation'] ); |
||||||
0 ignored issues
–
show
The method
setSalutation() does not exist on Aimeos\MShop\Attribute\Item\Iface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
150 | $addr->setCompany( $entry['company'] ); |
||||||
0 ignored issues
–
show
The method
setCompany() does not exist on Aimeos\MShop\Attribute\Item\Iface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
151 | $addr->setVatID( $entry['vatid'] ); |
||||||
0 ignored issues
–
show
The method
setVatID() does not exist on Aimeos\MShop\Attribute\Item\Iface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
152 | $addr->setFirstname( $entry['firstname'] ); |
||||||
0 ignored issues
–
show
The method
setFirstname() does not exist on Aimeos\MShop\Attribute\Item\Iface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
153 | $addr->setLastname( $entry['lastname'] ); |
||||||
0 ignored issues
–
show
The method
setLastname() does not exist on Aimeos\MShop\Attribute\Item\Iface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
154 | $addr->setAddress1( $entry['address1'] ); |
||||||
0 ignored issues
–
show
The method
setAddress1() does not exist on Aimeos\MShop\Attribute\Item\Iface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
155 | $addr->setAddress2( $entry['address2'] ); |
||||||
0 ignored issues
–
show
The method
setAddress2() does not exist on Aimeos\MShop\Attribute\Item\Iface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
156 | $addr->setAddress3( $entry['address3'] ); |
||||||
0 ignored issues
–
show
The method
setAddress3() does not exist on Aimeos\MShop\Attribute\Item\Iface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
157 | $addr->setPostal( $entry['postal'] ); |
||||||
0 ignored issues
–
show
The method
setPostal() does not exist on Aimeos\MShop\Attribute\Item\Iface . Did you maybe mean setPosition() ?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
158 | $addr->setCity( $entry['city'] ); |
||||||
0 ignored issues
–
show
The method
setCity() does not exist on Aimeos\MShop\Attribute\Item\Iface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
159 | $addr->setState( $entry['state'] ); |
||||||
0 ignored issues
–
show
The method
setState() does not exist on Aimeos\MShop\Attribute\Item\Iface . Did you maybe mean setStatus() ?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
160 | $addr->setLanguageId( $entry['langid'] ); |
||||||
0 ignored issues
–
show
The method
setLanguageId() does not exist on Aimeos\MShop\Attribute\Item\Iface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
161 | $addr->setCountryId( $entry['countryid'] ); |
||||||
0 ignored issues
–
show
The method
setCountryId() does not exist on Aimeos\MShop\Attribute\Item\Iface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
162 | $addr->setTelephone( $entry['telephone'] ); |
||||||
0 ignored issues
–
show
The method
setTelephone() does not exist on Aimeos\MShop\Attribute\Item\Iface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
163 | $addr->setEmail( $entry['email'] ); |
||||||
0 ignored issues
–
show
The method
setEmail() does not exist on Aimeos\MShop\Attribute\Item\Iface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
164 | $addr->setTelefax( $entry['telefax'] ); |
||||||
0 ignored issues
–
show
The method
setTelefax() does not exist on Aimeos\MShop\Attribute\Item\Iface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
165 | $addr->setWebsite( $entry['website'] ); |
||||||
0 ignored issues
–
show
The method
setWebsite() does not exist on Aimeos\MShop\Attribute\Item\Iface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
166 | |||||||
167 | $manager->saveItem( $addr ); |
||||||
168 | } |
||||||
169 | } |
||||||
170 | } |
||||||
171 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.