@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Empties the basket and removing all products, addresses, services, etc. |
64 | - * @return void |
|
64 | + * @return Base |
|
65 | 65 | */ |
66 | 66 | public function clear() |
67 | 67 | { |
@@ -134,11 +134,6 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @param string $prodid ID of the base product to add |
136 | 136 | * @param integer $quantity Amount of products that should by added |
137 | - * @param array $options Possible options are: 'stock'=>true|false and 'variant'=>true|false |
|
138 | - * The 'stock'=>false option allows adding products without being in stock. |
|
139 | - * The 'variant'=>false option allows adding the selection product to the basket |
|
140 | - * instead of the specific sub-product if the variant-building attribute IDs |
|
141 | - * doesn't match a specific sub-product or if the attribute IDs are missing. |
|
142 | 137 | * @param array $variantAttributeIds List of variant-building attribute IDs that identify a specific product |
143 | 138 | * in a selection products |
144 | 139 | * @param array $configAttributeIds List of attribute IDs that doesn't identify a specific product in a |
@@ -257,7 +252,7 @@ discard block |
||
257 | 252 | /** |
258 | 253 | * Returns the frontend controller |
259 | 254 | * |
260 | - * @return \Aimeos\Controller\Frontend\Basket\Iface Frontend controller object |
|
255 | + * @return \Aimeos\Controller\Frontend\Iface Frontend controller object |
|
261 | 256 | */ |
262 | 257 | protected function getController() |
263 | 258 | { |
@@ -30,18 +30,18 @@ discard block |
||
30 | 30 | * @param \Aimeos\Controller\Frontend\Iface $controller Controller object |
31 | 31 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects |
32 | 32 | */ |
33 | - public function __construct( \Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context ) |
|
33 | + public function __construct(\Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context) |
|
34 | 34 | { |
35 | 35 | $iface = '\Aimeos\Controller\Frontend\Basket\Iface'; |
36 | - if( !( $controller instanceof $iface ) ) |
|
36 | + if (!($controller instanceof $iface)) |
|
37 | 37 | { |
38 | - $msg = sprintf( 'Class "%1$s" does not implement interface "%2$s"', get_class( $controller ), $iface ); |
|
39 | - throw new \Aimeos\Controller\Frontend\Exception( $msg ); |
|
38 | + $msg = sprintf('Class "%1$s" does not implement interface "%2$s"', get_class($controller), $iface); |
|
39 | + throw new \Aimeos\Controller\Frontend\Exception($msg); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | $this->controller = $controller; |
43 | 43 | |
44 | - parent::__construct( $context ); |
|
44 | + parent::__construct($context); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | * @return mixed Returns the value of the called method |
54 | 54 | * @throws \Aimeos\Controller\Frontend\Exception If method call failed |
55 | 55 | */ |
56 | - public function __call( $name, array $param ) |
|
56 | + public function __call($name, array $param) |
|
57 | 57 | { |
58 | - return @call_user_func_array( array( $this->controller, $name ), $param ); |
|
58 | + return @call_user_func_array(array($this->controller, $name), $param); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | * @param string $type Basket type |
98 | 98 | * @return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object |
99 | 99 | */ |
100 | - public function setType( $type ) |
|
100 | + public function setType($type) |
|
101 | 101 | { |
102 | - $this->controller->setType( $type ); |
|
102 | + $this->controller->setType($type); |
|
103 | 103 | return $this; |
104 | 104 | } |
105 | 105 | |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | * @param boolean $default True to add default criteria (user logged in), false if not |
124 | 124 | * @return \Aimeos\MShop\Order\Item\Base\Iface Order base object including the given parts |
125 | 125 | */ |
126 | - public function load( $id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true ) |
|
126 | + public function load($id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true) |
|
127 | 127 | { |
128 | - return $this->controller->load( $id, $parts, $default ); |
|
128 | + return $this->controller->load($id, $parts, $default); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
151 | 151 | * @return void |
152 | 152 | */ |
153 | - public function addProduct( $prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
154 | - array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [] ) |
|
153 | + public function addProduct($prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
154 | + array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = []) |
|
155 | 155 | { |
156 | 156 | $this->controller->addProduct( |
157 | 157 | $prodid, $quantity, $stocktype, $variantAttributeIds, |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | * @param integer $position Position number (key) of the order product item |
167 | 167 | * @return void |
168 | 168 | */ |
169 | - public function deleteProduct( $position ) |
|
169 | + public function deleteProduct($position) |
|
170 | 170 | { |
171 | - $this->controller->deleteProduct( $position ); |
|
171 | + $this->controller->deleteProduct($position); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | * @param array $configAttributeCodes Codes of the product config attributes that should be REMOVED |
181 | 181 | * @return void |
182 | 182 | */ |
183 | - public function editProduct( $position, $quantity, array $configAttributeCodes = [] ) |
|
183 | + public function editProduct($position, $quantity, array $configAttributeCodes = []) |
|
184 | 184 | { |
185 | - $this->controller->editProduct( $position, $quantity, $configAttributeCodes ); |
|
185 | + $this->controller->editProduct($position, $quantity, $configAttributeCodes); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
194 | 194 | * @return void |
195 | 195 | */ |
196 | - public function addCoupon( $code ) |
|
196 | + public function addCoupon($code) |
|
197 | 197 | { |
198 | - $this->controller->addCoupon( $code ); |
|
198 | + $this->controller->addCoupon($code); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | |
@@ -206,9 +206,9 @@ discard block |
||
206 | 206 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
207 | 207 | * @return void |
208 | 208 | */ |
209 | - public function deleteCoupon( $code ) |
|
209 | + public function deleteCoupon($code) |
|
210 | 210 | { |
211 | - $this->controller->deleteCoupon( $code ); |
|
211 | + $this->controller->deleteCoupon($code); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | |
@@ -221,9 +221,9 @@ discard block |
||
221 | 221 | * if one of the keys is invalid when using an array with key/value pairs |
222 | 222 | * @return void |
223 | 223 | */ |
224 | - public function setAddress( $type, $value ) |
|
224 | + public function setAddress($type, $value) |
|
225 | 225 | { |
226 | - $this->controller->setAddress( $type, $value ); |
|
226 | + $this->controller->setAddress($type, $value); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | |
@@ -237,9 +237,9 @@ discard block |
||
237 | 237 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
238 | 238 | * @return void |
239 | 239 | */ |
240 | - public function addService( $type, $id, array $attributes = [] ) |
|
240 | + public function addService($type, $id, array $attributes = []) |
|
241 | 241 | { |
242 | - $this->controller->addService( $type, $id, $attributes ); |
|
242 | + $this->controller->addService($type, $id, $attributes); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @param string $type Service type code like 'payment' or 'delivery' |
250 | 250 | */ |
251 | - public function deleteService( $type ) |
|
251 | + public function deleteService($type) |
|
252 | 252 | { |
253 | - $this->controller->deleteService( $type ); |
|
253 | + $this->controller->deleteService($type); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 |
@@ -19,112 +19,112 @@ discard block |
||
19 | 19 | public static function setUpBeforeClass() |
20 | 20 | { |
21 | 21 | $context = \TestHelperFrontend::getContext(); |
22 | - self::$testItem = \Aimeos\MShop\Factory::createManager( $context, 'product' )->findItem( 'U:TESTP' ); |
|
22 | + self::$testItem = \Aimeos\MShop\Factory::createManager($context, 'product')->findItem('U:TESTP'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | |
26 | 26 | protected function setUp() |
27 | 27 | { |
28 | - \Aimeos\MShop\Factory::setCache( true ); |
|
28 | + \Aimeos\MShop\Factory::setCache(true); |
|
29 | 29 | |
30 | 30 | $this->context = \TestHelperFrontend::getContext(); |
31 | - $this->object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
31 | + $this->object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
35 | 35 | protected function tearDown() |
36 | 36 | { |
37 | - \Aimeos\MShop\Factory::setCache( false ); |
|
37 | + \Aimeos\MShop\Factory::setCache(false); |
|
38 | 38 | \Aimeos\MShop\Factory::clear(); |
39 | 39 | |
40 | 40 | $this->object->clear(); |
41 | - $this->context->getSession()->set( 'aimeos', [] ); |
|
41 | + $this->context->getSession()->set('aimeos', []); |
|
42 | 42 | |
43 | - unset( $this->context, $this->object ); |
|
43 | + unset($this->context, $this->object); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
47 | 47 | public function testClear() |
48 | 48 | { |
49 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
49 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
50 | 50 | $this->object->clear(); |
51 | 51 | |
52 | - $this->assertEquals( 0, count( $this->object->get()->getProducts() ) ); |
|
52 | + $this->assertEquals(0, count($this->object->get()->getProducts())); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | |
56 | 56 | public function testGet() |
57 | 57 | { |
58 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Base\Iface', $this->object->get() ); |
|
58 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Base\Iface', $this->object->get()); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
62 | 62 | public function testSave() |
63 | 63 | { |
64 | - $stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' ) |
|
65 | - ->setConstructorArgs( [$this->context] ) |
|
66 | - ->setMethods( ['setSession'] ) |
|
64 | + $stub = $this->getMockBuilder('\Aimeos\MShop\Order\Manager\Base\Standard') |
|
65 | + ->setConstructorArgs([$this->context]) |
|
66 | + ->setMethods(['setSession']) |
|
67 | 67 | ->getMock(); |
68 | 68 | |
69 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub ); |
|
69 | + \Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $stub); |
|
70 | 70 | |
71 | - $stub->expects( $this->exactly( 2 ) )->method( 'setSession' ); |
|
71 | + $stub->expects($this->exactly(2))->method('setSession'); |
|
72 | 72 | |
73 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
74 | - $object->addProduct( self::$testItem->getId(), 2 ); |
|
73 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
74 | + $object->addProduct(self::$testItem->getId(), 2); |
|
75 | 75 | $object->save(); |
76 | 76 | } |
77 | 77 | |
78 | 78 | |
79 | 79 | public function testSetType() |
80 | 80 | { |
81 | - $this->assertInstanceOf( '\Aimeos\Controller\Frontend\Basket\Iface', $this->object->setType( 'test' ) ); |
|
81 | + $this->assertInstanceOf('\Aimeos\Controller\Frontend\Basket\Iface', $this->object->setType('test')); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
85 | 85 | public function testStore() |
86 | 86 | { |
87 | - $stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' ) |
|
88 | - ->setConstructorArgs( [$this->context] ) |
|
89 | - ->setMethods( ['store'] ) |
|
87 | + $stub = $this->getMockBuilder('\Aimeos\MShop\Order\Manager\Base\Standard') |
|
88 | + ->setConstructorArgs([$this->context]) |
|
89 | + ->setMethods(['store']) |
|
90 | 90 | ->getMock(); |
91 | 91 | |
92 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub ); |
|
92 | + \Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $stub); |
|
93 | 93 | |
94 | - $stub->expects( $this->once() )->method( 'store' ); |
|
94 | + $stub->expects($this->once())->method('store'); |
|
95 | 95 | |
96 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
96 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
97 | 97 | $object->store(); |
98 | 98 | } |
99 | 99 | |
100 | 100 | |
101 | 101 | public function testStoreLimit() |
102 | 102 | { |
103 | - $this->context->setEditor( 'core:unittest' ); |
|
103 | + $this->context->setEditor('core:unittest'); |
|
104 | 104 | $config = $this->context->getConfig(); |
105 | - $config->set( 'controller/frontend/basket/limit-count', 0 ); |
|
106 | - $config->set( 'controller/frontend/basket/limit-seconds', 86400 * 365 ); |
|
105 | + $config->set('controller/frontend/basket/limit-count', 0); |
|
106 | + $config->set('controller/frontend/basket/limit-seconds', 86400 * 365); |
|
107 | 107 | |
108 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
108 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
109 | 109 | |
110 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Basket\Exception' ); |
|
110 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Basket\Exception'); |
|
111 | 111 | $object->store(); |
112 | 112 | } |
113 | 113 | |
114 | 114 | |
115 | 115 | public function testLoad() |
116 | 116 | { |
117 | - $stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' ) |
|
118 | - ->setConstructorArgs( [$this->context] ) |
|
119 | - ->setMethods( ['load'] ) |
|
117 | + $stub = $this->getMockBuilder('\Aimeos\MShop\Order\Manager\Base\Standard') |
|
118 | + ->setConstructorArgs([$this->context]) |
|
119 | + ->setMethods(['load']) |
|
120 | 120 | ->getMock(); |
121 | 121 | |
122 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub ); |
|
122 | + \Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $stub); |
|
123 | 123 | |
124 | - $stub->expects( $this->once() )->method( 'load' ) |
|
125 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
124 | + $stub->expects($this->once())->method('load') |
|
125 | + ->will($this->returnValue($stub->createItem())); |
|
126 | 126 | |
127 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
127 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
128 | 128 | $object->load( -1 ); |
129 | 129 | } |
130 | 130 | |
@@ -132,338 +132,338 @@ discard block |
||
132 | 132 | public function testAddDeleteProduct() |
133 | 133 | { |
134 | 134 | $basket = $this->object->get(); |
135 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' ); |
|
135 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC'); |
|
136 | 136 | |
137 | - $this->object->addProduct( $item->getId(), 2, 'default', [], [], [], [] ); |
|
138 | - $item2 = $this->object->get()->getProduct( 0 ); |
|
139 | - $this->object->deleteProduct( 0 ); |
|
137 | + $this->object->addProduct($item->getId(), 2, 'default', [], [], [], []); |
|
138 | + $item2 = $this->object->get()->getProduct(0); |
|
139 | + $this->object->deleteProduct(0); |
|
140 | 140 | |
141 | - $this->assertEquals( 0, count( $basket->getProducts() ) ); |
|
142 | - $this->assertEquals( 'CNC', $item2->getProductCode() ); |
|
141 | + $this->assertEquals(0, count($basket->getProducts())); |
|
142 | + $this->assertEquals('CNC', $item2->getProductCode()); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | |
146 | 146 | public function testAddProductCustomAttribute() |
147 | 147 | { |
148 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
148 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
149 | 149 | |
150 | 150 | $search = $attributeManager->createSearch(); |
151 | 151 | $expr = array( |
152 | - $search->compare( '==', 'attribute.code', 'custom' ), |
|
153 | - $search->compare( '==', 'attribute.type.code', 'date' ), |
|
152 | + $search->compare('==', 'attribute.code', 'custom'), |
|
153 | + $search->compare('==', 'attribute.type.code', 'date'), |
|
154 | 154 | ); |
155 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
155 | + $search->setConditions($search->combine('&&', $expr)); |
|
156 | 156 | |
157 | - $attributes = $attributeManager->searchItems( $search ); |
|
157 | + $attributes = $attributeManager->searchItems($search); |
|
158 | 158 | |
159 | - if( ( $attrItem = reset( $attributes ) ) === false ) { |
|
160 | - throw new \RuntimeException( 'Attribute not found' ); |
|
159 | + if (($attrItem = reset($attributes)) === false) { |
|
160 | + throw new \RuntimeException('Attribute not found'); |
|
161 | 161 | } |
162 | 162 | |
163 | - $attrValues = array( $attrItem->getId() => '2000-01-01' ); |
|
163 | + $attrValues = array($attrItem->getId() => '2000-01-01'); |
|
164 | 164 | |
165 | - $this->object->addProduct( self::$testItem->getId(), 1, 'default', [], [], [], $attrValues ); |
|
165 | + $this->object->addProduct(self::$testItem->getId(), 1, 'default', [], [], [], $attrValues); |
|
166 | 166 | $basket = $this->object->get(); |
167 | 167 | |
168 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
169 | - $this->assertEquals( '2000-01-01', $basket->getProduct( 0 )->getAttribute( 'date', 'custom' ) ); |
|
168 | + $this->assertEquals(1, count($basket->getProducts())); |
|
169 | + $this->assertEquals('2000-01-01', $basket->getProduct(0)->getAttribute('date', 'custom')); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | |
173 | 173 | public function testAddProductCustomPrice() |
174 | 174 | { |
175 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
175 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
176 | 176 | |
177 | 177 | $search = $attributeManager->createSearch(); |
178 | 178 | $expr = array( |
179 | - $search->compare( '==', 'attribute.code', 'custom' ), |
|
180 | - $search->compare( '==', 'attribute.type.code', 'price' ), |
|
179 | + $search->compare('==', 'attribute.code', 'custom'), |
|
180 | + $search->compare('==', 'attribute.type.code', 'price'), |
|
181 | 181 | ); |
182 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
182 | + $search->setConditions($search->combine('&&', $expr)); |
|
183 | 183 | |
184 | - $attributes = $attributeManager->searchItems( $search ); |
|
184 | + $attributes = $attributeManager->searchItems($search); |
|
185 | 185 | |
186 | - if( ( $attrItem = reset( $attributes ) ) === false ) { |
|
187 | - throw new \RuntimeException( 'Attribute not found' ); |
|
186 | + if (($attrItem = reset($attributes)) === false) { |
|
187 | + throw new \RuntimeException('Attribute not found'); |
|
188 | 188 | } |
189 | 189 | |
190 | - $attrValues = array( $attrItem->getId() => '0.01' ); |
|
190 | + $attrValues = array($attrItem->getId() => '0.01'); |
|
191 | 191 | |
192 | - $this->object->addProduct( self::$testItem->getId(), 1, 'default', [], [], [], $attrValues ); |
|
192 | + $this->object->addProduct(self::$testItem->getId(), 1, 'default', [], [], [], $attrValues); |
|
193 | 193 | $basket = $this->object->get(); |
194 | 194 | |
195 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
196 | - $this->assertEquals( '0.01', $basket->getProduct( 0 )->getPrice()->getValue() ); |
|
195 | + $this->assertEquals(1, count($basket->getProducts())); |
|
196 | + $this->assertEquals('0.01', $basket->getProduct(0)->getPrice()->getValue()); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | |
200 | 200 | public function testAddProductCustomPriceException() |
201 | 201 | { |
202 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
202 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
203 | 203 | |
204 | 204 | $search = $attributeManager->createSearch(); |
205 | 205 | $expr = array( |
206 | - $search->compare( '==', 'attribute.code', 'custom' ), |
|
207 | - $search->compare( '==', 'attribute.type.code', 'price' ), |
|
206 | + $search->compare('==', 'attribute.code', 'custom'), |
|
207 | + $search->compare('==', 'attribute.type.code', 'price'), |
|
208 | 208 | ); |
209 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
209 | + $search->setConditions($search->combine('&&', $expr)); |
|
210 | 210 | |
211 | - $attributes = $attributeManager->searchItems( $search ); |
|
211 | + $attributes = $attributeManager->searchItems($search); |
|
212 | 212 | |
213 | - if( ( $attrItem = reset( $attributes ) ) === false ) { |
|
214 | - throw new \RuntimeException( 'Attribute not found' ); |
|
213 | + if (($attrItem = reset($attributes)) === false) { |
|
214 | + throw new \RuntimeException('Attribute not found'); |
|
215 | 215 | } |
216 | 216 | |
217 | - $attrValues = array( $attrItem->getId() => ',' ); |
|
217 | + $attrValues = array($attrItem->getId() => ','); |
|
218 | 218 | |
219 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Basket\Exception' ); |
|
220 | - $this->object->addProduct( self::$testItem->getId(), 1, 'default', [], [], [], $attrValues ); |
|
219 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Basket\Exception'); |
|
220 | + $this->object->addProduct(self::$testItem->getId(), 1, 'default', [], [], [], $attrValues); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | |
224 | 224 | public function testAddProductAttributePrice() |
225 | 225 | { |
226 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
226 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
227 | 227 | |
228 | 228 | $search = $attributeManager->createSearch(); |
229 | 229 | $expr = array( |
230 | - $search->compare( '==', 'attribute.code', 'xs' ), |
|
231 | - $search->compare( '==', 'attribute.type.code', 'size' ), |
|
230 | + $search->compare('==', 'attribute.code', 'xs'), |
|
231 | + $search->compare('==', 'attribute.type.code', 'size'), |
|
232 | 232 | ); |
233 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
233 | + $search->setConditions($search->combine('&&', $expr)); |
|
234 | 234 | |
235 | - $attributes = $attributeManager->searchItems( $search ); |
|
235 | + $attributes = $attributeManager->searchItems($search); |
|
236 | 236 | |
237 | - if( ( $attribute = reset( $attributes ) ) === false ) { |
|
238 | - throw new \RuntimeException( 'Attribute not found' ); |
|
237 | + if (($attribute = reset($attributes)) === false) { |
|
238 | + throw new \RuntimeException('Attribute not found'); |
|
239 | 239 | } |
240 | 240 | |
241 | - $this->object->addProduct( self::$testItem->getId(), 1, 'default', [], [$attribute->getId() => 2] ); |
|
241 | + $this->object->addProduct(self::$testItem->getId(), 1, 'default', [], [$attribute->getId() => 2]); |
|
242 | 242 | |
243 | - $this->assertEquals( '43.90', $this->object->get()->getPrice()->getValue() ); |
|
243 | + $this->assertEquals('43.90', $this->object->get()->getPrice()->getValue()); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | |
247 | 247 | public function testAddProductAttributeNotAssigned() |
248 | 248 | { |
249 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
249 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
250 | 250 | |
251 | 251 | $search = $attributeManager->createSearch(); |
252 | 252 | $expr = array( |
253 | - $search->compare( '==', 'attribute.code', '30' ), |
|
254 | - $search->compare( '==', 'attribute.type.code', 'width' ), |
|
253 | + $search->compare('==', 'attribute.code', '30'), |
|
254 | + $search->compare('==', 'attribute.type.code', 'width'), |
|
255 | 255 | ); |
256 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
256 | + $search->setConditions($search->combine('&&', $expr)); |
|
257 | 257 | |
258 | - $attribute = $attributeManager->searchItems( $search ); |
|
258 | + $attribute = $attributeManager->searchItems($search); |
|
259 | 259 | |
260 | - if( empty( $attribute ) ) { |
|
261 | - throw new \RuntimeException( 'Attribute not found' ); |
|
260 | + if (empty($attribute)) { |
|
261 | + throw new \RuntimeException('Attribute not found'); |
|
262 | 262 | } |
263 | 263 | |
264 | - $hiddenAttrIds = array_keys( $attribute ); |
|
265 | - $configAttrIds = array_keys( $attribute ); |
|
264 | + $hiddenAttrIds = array_keys($attribute); |
|
265 | + $configAttrIds = array_keys($attribute); |
|
266 | 266 | |
267 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
268 | - $this->object->addProduct( self::$testItem->getId(), 1, 'default', [], $configAttrIds, $hiddenAttrIds ); |
|
267 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
268 | + $this->object->addProduct(self::$testItem->getId(), 1, 'default', [], $configAttrIds, $hiddenAttrIds); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | |
272 | 272 | public function testAddProductNegativeQuantityException() |
273 | 273 | { |
274 | - $this->setExpectedException( '\\Aimeos\\MShop\\Order\\Exception' ); |
|
275 | - $this->object->addProduct( self::$testItem->getId(), -1 ); |
|
274 | + $this->setExpectedException('\\Aimeos\\MShop\\Order\\Exception'); |
|
275 | + $this->object->addProduct(self::$testItem->getId(), -1); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | |
279 | 279 | public function testAddProductNoPriceException() |
280 | 280 | { |
281 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'MNOP' ); |
|
281 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('MNOP'); |
|
282 | 282 | |
283 | - $this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' ); |
|
284 | - $this->object->addProduct( $item->getId(), 1 ); |
|
283 | + $this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception'); |
|
284 | + $this->object->addProduct($item->getId(), 1); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | |
288 | 288 | public function testAddProductConfigAttributeException() |
289 | 289 | { |
290 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
291 | - $this->object->addProduct( self::$testItem->getId(), 1, 'default', [], array( -1 ) ); |
|
290 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
291 | + $this->object->addProduct(self::$testItem->getId(), 1, 'default', [], array( -1 )); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | |
295 | 295 | public function testAddProductLowQuantityPriceException() |
296 | 296 | { |
297 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' ); |
|
297 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL'); |
|
298 | 298 | |
299 | - $this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' ); |
|
300 | - $this->object->addProduct( $item->getId(), 1 ); |
|
299 | + $this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception'); |
|
300 | + $this->object->addProduct($item->getId(), 1); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
304 | 304 | public function testAddProductHigherQuantities() |
305 | 305 | { |
306 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' ); |
|
306 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL'); |
|
307 | 307 | |
308 | - $this->object->addProduct( $item->getId(), 2, 'default', [], [], [], [], 'unit_type3' ); |
|
308 | + $this->object->addProduct($item->getId(), 2, 'default', [], [], [], [], 'unit_type3'); |
|
309 | 309 | |
310 | - $this->assertEquals( 2, $this->object->get()->getProduct( 0 )->getQuantity() ); |
|
311 | - $this->assertEquals( 'IJKL', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
310 | + $this->assertEquals(2, $this->object->get()->getProduct(0)->getQuantity()); |
|
311 | + $this->assertEquals('IJKL', $this->object->get()->getProduct(0)->getProductCode()); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | |
315 | 315 | public function testDeleteProductFlagError() |
316 | 316 | { |
317 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
317 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
318 | 318 | |
319 | - $item = $this->object->get()->getProduct( 0 ); |
|
320 | - $item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ); |
|
319 | + $item = $this->object->get()->getProduct(0); |
|
320 | + $item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE); |
|
321 | 321 | |
322 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
323 | - $this->object->deleteProduct( 0 ); |
|
322 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
323 | + $this->object->deleteProduct(0); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | |
327 | 327 | public function testEditProduct() |
328 | 328 | { |
329 | - $this->object->addProduct( self::$testItem->getId(), 1 ); |
|
329 | + $this->object->addProduct(self::$testItem->getId(), 1); |
|
330 | 330 | |
331 | - $item = $this->object->get()->getProduct( 0 ); |
|
332 | - $this->assertEquals( 1, $item->getQuantity() ); |
|
331 | + $item = $this->object->get()->getProduct(0); |
|
332 | + $this->assertEquals(1, $item->getQuantity()); |
|
333 | 333 | |
334 | - $this->object->editProduct( 0, 4 ); |
|
334 | + $this->object->editProduct(0, 4); |
|
335 | 335 | |
336 | - $item = $this->object->get()->getProduct( 0 ); |
|
337 | - $this->assertEquals( 4, $item->getQuantity() ); |
|
338 | - $this->assertEquals( 'U:TESTP', $item->getProductCode() ); |
|
336 | + $item = $this->object->get()->getProduct(0); |
|
337 | + $this->assertEquals(4, $item->getQuantity()); |
|
338 | + $this->assertEquals('U:TESTP', $item->getProductCode()); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | |
342 | 342 | public function testEditProductAttributes() |
343 | 343 | { |
344 | 344 | $configAttrIds = []; |
345 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
345 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
346 | 346 | |
347 | 347 | $search = $attributeManager->createSearch(); |
348 | 348 | $conditions = array( |
349 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
350 | - $search->combine( '||', array( |
|
351 | - $search->combine( '&&', array( |
|
352 | - $search->compare( '==', 'attribute.code', 'xs' ), |
|
353 | - $search->compare( '==', 'attribute.type.code', 'size' ), |
|
354 | - ) ), |
|
355 | - $search->combine( '&&', array( |
|
356 | - $search->compare( '==', 'attribute.code', 'white' ), |
|
357 | - $search->compare( '==', 'attribute.type.code', 'color' ), |
|
358 | - ) ), |
|
359 | - ) ) |
|
349 | + $search->compare('==', 'attribute.domain', 'product'), |
|
350 | + $search->combine('||', array( |
|
351 | + $search->combine('&&', array( |
|
352 | + $search->compare('==', 'attribute.code', 'xs'), |
|
353 | + $search->compare('==', 'attribute.type.code', 'size'), |
|
354 | + )), |
|
355 | + $search->combine('&&', array( |
|
356 | + $search->compare('==', 'attribute.code', 'white'), |
|
357 | + $search->compare('==', 'attribute.type.code', 'color'), |
|
358 | + )), |
|
359 | + )) |
|
360 | 360 | ); |
361 | - $search->setConditions( $search->combine( '&&', $conditions ) ); |
|
362 | - $attributes = $attributeManager->searchItems( $search ); |
|
361 | + $search->setConditions($search->combine('&&', $conditions)); |
|
362 | + $attributes = $attributeManager->searchItems($search); |
|
363 | 363 | |
364 | - if( empty( $attributes ) ) { |
|
365 | - throw new \RuntimeException( 'No attributes available' ); |
|
364 | + if (empty($attributes)) { |
|
365 | + throw new \RuntimeException('No attributes available'); |
|
366 | 366 | } |
367 | 367 | |
368 | - foreach( $attributes as $id => $attribute ) { |
|
368 | + foreach ($attributes as $id => $attribute) { |
|
369 | 369 | $configAttrIds[$id] = 1; |
370 | 370 | } |
371 | 371 | |
372 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TESTP' ); |
|
372 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TESTP'); |
|
373 | 373 | |
374 | - $this->object->addProduct( $item->getId(), 1, 'default', [], $configAttrIds ); |
|
375 | - $this->object->editProduct( 0, 4 ); |
|
374 | + $this->object->addProduct($item->getId(), 1, 'default', [], $configAttrIds); |
|
375 | + $this->object->editProduct(0, 4); |
|
376 | 376 | |
377 | - $item = $this->object->get()->getProduct( 0 ); |
|
378 | - $this->assertEquals( 2, count( $item->getAttributes() ) ); |
|
379 | - $this->assertEquals( 4, $item->getQuantity() ); |
|
377 | + $item = $this->object->get()->getProduct(0); |
|
378 | + $this->assertEquals(2, count($item->getAttributes())); |
|
379 | + $this->assertEquals(4, $item->getQuantity()); |
|
380 | 380 | |
381 | 381 | |
382 | - $this->object->editProduct( 0, 3, array( reset( $attributes )->getType() ) ); |
|
382 | + $this->object->editProduct(0, 3, array(reset($attributes)->getType())); |
|
383 | 383 | |
384 | - $item = $this->object->get()->getProduct( 0 ); |
|
385 | - $this->assertEquals( 3, $item->getQuantity() ); |
|
386 | - $this->assertEquals( 1, count( $item->getAttributes() ) ); |
|
387 | - $this->assertEquals( 'U:TESTP', $item->getProductCode() ); |
|
384 | + $item = $this->object->get()->getProduct(0); |
|
385 | + $this->assertEquals(3, $item->getQuantity()); |
|
386 | + $this->assertEquals(1, count($item->getAttributes())); |
|
387 | + $this->assertEquals('U:TESTP', $item->getProductCode()); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | |
391 | 391 | public function testEditProductFlagError() |
392 | 392 | { |
393 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
393 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
394 | 394 | |
395 | - $item = $this->object->get()->getProduct( 0 ); |
|
396 | - $item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ); |
|
395 | + $item = $this->object->get()->getProduct(0); |
|
396 | + $item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE); |
|
397 | 397 | |
398 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
399 | - $this->object->editProduct( 0, 4 ); |
|
398 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
399 | + $this->object->editProduct(0, 4); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | |
403 | 403 | public function testAddCoupon() |
404 | 404 | { |
405 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
406 | - $this->object->addCoupon( 'GHIJ' ); |
|
405 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
406 | + $this->object->addCoupon('GHIJ'); |
|
407 | 407 | |
408 | 408 | $basket = $this->object->get(); |
409 | 409 | |
410 | - $this->assertEquals( 1, count( $basket->getCoupons() ) ); |
|
410 | + $this->assertEquals(1, count($basket->getCoupons())); |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | |
414 | 414 | public function testAddCouponExceedCount() |
415 | 415 | { |
416 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
417 | - $this->object->addCoupon( 'GHIJ' ); |
|
416 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
417 | + $this->object->addCoupon('GHIJ'); |
|
418 | 418 | |
419 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
420 | - $this->object->addCoupon( 'GHIJ' ); |
|
419 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
420 | + $this->object->addCoupon('GHIJ'); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | |
424 | 424 | public function testAddCouponInvalidCode() |
425 | 425 | { |
426 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
427 | - $this->object->addCoupon( 'invalid' ); |
|
426 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
427 | + $this->object->addCoupon('invalid'); |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | |
431 | 431 | public function testAddCouponMissingRequirements() |
432 | 432 | { |
433 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
434 | - $this->object->addCoupon( 'OPQR' ); |
|
433 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
434 | + $this->object->addCoupon('OPQR'); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | |
438 | 438 | public function testDeleteCoupon() |
439 | 439 | { |
440 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
441 | - $this->object->addCoupon( '90AB' ); |
|
442 | - $this->object->deleteCoupon( '90AB' ); |
|
440 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
441 | + $this->object->addCoupon('90AB'); |
|
442 | + $this->object->deleteCoupon('90AB'); |
|
443 | 443 | |
444 | 444 | $basket = $this->object->get(); |
445 | 445 | |
446 | - $this->assertEquals( 0, count( $basket->getCoupons() ) ); |
|
446 | + $this->assertEquals(0, count($basket->getCoupons())); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | |
450 | 450 | public function testSetAddressDelete() |
451 | 451 | { |
452 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null ); |
|
452 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null); |
|
453 | 453 | |
454 | - $this->setExpectedException( '\Aimeos\MShop\Order\Exception' ); |
|
455 | - $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
454 | + $this->setExpectedException('\Aimeos\MShop\Order\Exception'); |
|
455 | + $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | |
459 | 459 | public function testSetBillingAddressByItem() |
460 | 460 | { |
461 | - $item = $this->getAddress( 'Example company' ); |
|
461 | + $item = $this->getAddress('Example company'); |
|
462 | 462 | |
463 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item ); |
|
463 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item); |
|
464 | 464 | |
465 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
466 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
465 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
466 | + $this->assertEquals('Example company', $address->getCompany()); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | |
@@ -491,37 +491,37 @@ discard block |
||
491 | 491 | 'order.base.address.flag' => 0, |
492 | 492 | ); |
493 | 493 | |
494 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture ); |
|
494 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture); |
|
495 | 495 | |
496 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
497 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
498 | - $this->assertEquals( 'Dr.', $address->getTitle() ); |
|
499 | - $this->assertEquals( 'firstunit', $address->getFirstname() ); |
|
496 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
497 | + $this->assertEquals('Example company', $address->getCompany()); |
|
498 | + $this->assertEquals('Dr.', $address->getTitle()); |
|
499 | + $this->assertEquals('firstunit', $address->getFirstname()); |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | |
503 | 503 | public function testSetBillingAddressByArrayError() |
504 | 504 | { |
505 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
506 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array( 'error' => false ) ); |
|
505 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
506 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array('error' => false)); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | |
510 | 510 | public function testSetBillingAddressParameterError() |
511 | 511 | { |
512 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
513 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error' ); |
|
512 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
513 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error'); |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | |
517 | 517 | public function testSetDeliveryAddressByItem() |
518 | 518 | { |
519 | - $item = $this->getAddress( 'Example company' ); |
|
519 | + $item = $this->getAddress('Example company'); |
|
520 | 520 | |
521 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item ); |
|
521 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item); |
|
522 | 522 | |
523 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY ); |
|
524 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
523 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY); |
|
524 | + $this->assertEquals('Example company', $address->getCompany()); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | |
@@ -548,121 +548,121 @@ discard block |
||
548 | 548 | 'order.base.address.website' => 'www.example.com', |
549 | 549 | 'order.base.address.flag' => 0, |
550 | 550 | ); |
551 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture ); |
|
551 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture); |
|
552 | 552 | |
553 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY ); |
|
554 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
555 | - $this->assertEquals( 'Dr.', $address->getTitle() ); |
|
556 | - $this->assertEquals( 'firstunit', $address->getFirstname() ); |
|
553 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY); |
|
554 | + $this->assertEquals('Example company', $address->getCompany()); |
|
555 | + $this->assertEquals('Dr.', $address->getTitle()); |
|
556 | + $this->assertEquals('firstunit', $address->getFirstname()); |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | |
560 | 560 | public function testSetDeliveryAddressByArrayError() |
561 | 561 | { |
562 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
563 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array( 'error' => false ) ); |
|
562 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
563 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array('error' => false)); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | |
567 | 567 | public function testSetDeliveryAddressTypeError() |
568 | 568 | { |
569 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
570 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error' ); |
|
569 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
570 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error'); |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | |
574 | 574 | public function testSetServicePayment() |
575 | 575 | { |
576 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
577 | - $service = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' ); |
|
576 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
577 | + $service = $manager->findItem('unitpaymentcode', [], 'service', 'payment'); |
|
578 | 578 | |
579 | - $this->object->addService( 'payment', $service->getId(), [] ); |
|
580 | - $item = $this->object->get()->getService( 'payment', 'unitpaymentcode' )->getCode(); |
|
581 | - $this->assertEquals( 'unitpaymentcode', $item ); |
|
579 | + $this->object->addService('payment', $service->getId(), []); |
|
580 | + $item = $this->object->get()->getService('payment', 'unitpaymentcode')->getCode(); |
|
581 | + $this->assertEquals('unitpaymentcode', $item); |
|
582 | 582 | |
583 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
584 | - $this->object->addService( 'payment', $service->getId(), array( 'prepay' => true ) ); |
|
583 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
584 | + $this->object->addService('payment', $service->getId(), array('prepay' => true)); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | |
588 | 588 | public function testSetDeliveryOption() |
589 | 589 | { |
590 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
591 | - $service = $manager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
590 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
591 | + $service = $manager->findItem('unitcode', [], 'service', 'delivery'); |
|
592 | 592 | |
593 | - $this->object->addService( 'delivery', $service->getId(), [] ); |
|
594 | - $item = $this->object->get()->getService( 'delivery', 'unitcode' ); |
|
595 | - $this->assertEquals( 'unitcode', $item->getCode() ); |
|
593 | + $this->object->addService('delivery', $service->getId(), []); |
|
594 | + $item = $this->object->get()->getService('delivery', 'unitcode'); |
|
595 | + $this->assertEquals('unitcode', $item->getCode()); |
|
596 | 596 | |
597 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
598 | - $this->object->addService( 'delivery', $service->getId(), array( 'fast shipping' => true, 'air shipping' => false ) ); |
|
597 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
598 | + $this->object->addService('delivery', $service->getId(), array('fast shipping' => true, 'air shipping' => false)); |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | |
602 | 602 | public function testCheckLocale() |
603 | 603 | { |
604 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
605 | - $payment = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' ); |
|
606 | - $delivery = $manager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
604 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
605 | + $payment = $manager->findItem('unitpaymentcode', [], 'service', 'payment'); |
|
606 | + $delivery = $manager->findItem('unitcode', [], 'service', 'delivery'); |
|
607 | 607 | |
608 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
609 | - $this->object->addCoupon( 'OPQR' ); |
|
608 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
609 | + $this->object->addCoupon('OPQR'); |
|
610 | 610 | |
611 | - $this->object->addService( 'payment', $payment->getId() ); |
|
612 | - $this->object->addService( 'delivery', $delivery->getId() ); |
|
611 | + $this->object->addService('payment', $payment->getId()); |
|
612 | + $this->object->addService('delivery', $delivery->getId()); |
|
613 | 613 | |
614 | 614 | $basket = $this->object->get(); |
615 | 615 | $price = $basket->getPrice(); |
616 | 616 | |
617 | - foreach( $basket->getProducts() as $product ) |
|
617 | + foreach ($basket->getProducts() as $product) |
|
618 | 618 | { |
619 | - $this->assertEquals( 2, $product->getQuantity() ); |
|
620 | - $product->getPrice()->setCurrencyId( 'CHF' ); |
|
619 | + $this->assertEquals(2, $product->getQuantity()); |
|
620 | + $product->getPrice()->setCurrencyId('CHF'); |
|
621 | 621 | } |
622 | 622 | |
623 | - $basket->getService( 'delivery', 'unitcode' )->getPrice()->setCurrencyId( 'CHF' ); |
|
624 | - $basket->getService( 'payment', 'unitpaymentcode' )->getPrice()->setCurrencyId( 'CHF' ); |
|
625 | - $basket->getLocale()->setCurrencyId( 'CHF' ); |
|
626 | - $price->setCurrencyId( 'CHF' ); |
|
623 | + $basket->getService('delivery', 'unitcode')->getPrice()->setCurrencyId('CHF'); |
|
624 | + $basket->getService('payment', 'unitpaymentcode')->getPrice()->setCurrencyId('CHF'); |
|
625 | + $basket->getLocale()->setCurrencyId('CHF'); |
|
626 | + $price->setCurrencyId('CHF'); |
|
627 | 627 | |
628 | - $this->context->getLocale()->setCurrencyId( 'CHF' ); |
|
629 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress( 'Example company' ) ); |
|
628 | + $this->context->getLocale()->setCurrencyId('CHF'); |
|
629 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress('Example company')); |
|
630 | 630 | |
631 | - $this->context->getSession()->set( 'aimeos/basket/currency', 'CHF' ); |
|
632 | - $this->context->getLocale()->setCurrencyId( 'EUR' ); |
|
631 | + $this->context->getSession()->set('aimeos/basket/currency', 'CHF'); |
|
632 | + $this->context->getLocale()->setCurrencyId('EUR'); |
|
633 | 633 | |
634 | - $this->context->getSession()->set( 'aimeos/basket/content-unittest-en-EUR-', null ); |
|
634 | + $this->context->getSession()->set('aimeos/basket/content-unittest-en-EUR-', null); |
|
635 | 635 | |
636 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
636 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
637 | 637 | $basket = $object->get(); |
638 | 638 | |
639 | - foreach( $basket->getProducts() as $product ) |
|
639 | + foreach ($basket->getProducts() as $product) |
|
640 | 640 | { |
641 | - $this->assertEquals( 'EUR', $product->getPrice()->getCurrencyId() ); |
|
642 | - $this->assertEquals( 2, $product->getQuantity() ); |
|
641 | + $this->assertEquals('EUR', $product->getPrice()->getCurrencyId()); |
|
642 | + $this->assertEquals(2, $product->getQuantity()); |
|
643 | 643 | } |
644 | 644 | |
645 | - $this->assertEquals( 'EUR', $basket->getService( 'payment', 'unitpaymentcode' )->getPrice()->getCurrencyId() ); |
|
646 | - $this->assertEquals( 'EUR', $basket->getService( 'delivery', 'unitcode' )->getPrice()->getCurrencyId() ); |
|
647 | - $this->assertEquals( 'EUR', $basket->getLocale()->getCurrencyId() ); |
|
648 | - $this->assertEquals( 'EUR', $basket->getPrice()->getCurrencyId() ); |
|
645 | + $this->assertEquals('EUR', $basket->getService('payment', 'unitpaymentcode')->getPrice()->getCurrencyId()); |
|
646 | + $this->assertEquals('EUR', $basket->getService('delivery', 'unitcode')->getPrice()->getCurrencyId()); |
|
647 | + $this->assertEquals('EUR', $basket->getLocale()->getCurrencyId()); |
|
648 | + $this->assertEquals('EUR', $basket->getPrice()->getCurrencyId()); |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | |
652 | 652 | /** |
653 | 653 | * @param string $company |
654 | 654 | */ |
655 | - protected function getAddress( $company ) |
|
655 | + protected function getAddress($company) |
|
656 | 656 | { |
657 | - $customer = \Aimeos\MShop\Customer\Manager\Factory::createManager( \TestHelperFrontend::getContext(), 'Standard' ); |
|
658 | - $addressManager = $customer->getSubManager( 'address', 'Standard' ); |
|
657 | + $customer = \Aimeos\MShop\Customer\Manager\Factory::createManager(\TestHelperFrontend::getContext(), 'Standard'); |
|
658 | + $addressManager = $customer->getSubManager('address', 'Standard'); |
|
659 | 659 | |
660 | 660 | $search = $addressManager->createSearch(); |
661 | - $search->setConditions( $search->compare( '==', 'customer.address.company', $company ) ); |
|
662 | - $items = $addressManager->searchItems( $search ); |
|
661 | + $search->setConditions($search->compare('==', 'customer.address.company', $company)); |
|
662 | + $items = $addressManager->searchItems($search); |
|
663 | 663 | |
664 | - if( ( $item = reset( $items ) ) === false ) { |
|
665 | - throw new \RuntimeException( sprintf( 'No address item with company "%1$s" found', $company ) ); |
|
664 | + if (($item = reset($items)) === false) { |
|
665 | + throw new \RuntimeException(sprintf('No address item with company "%1$s" found', $company)); |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | return $item; |
@@ -19,219 +19,219 @@ |
||
19 | 19 | protected function setUp() |
20 | 20 | { |
21 | 21 | $this->context = \TestHelperFrontend::getContext(); |
22 | - $this->testItem = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TESTP' ); |
|
22 | + $this->testItem = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TESTP'); |
|
23 | 23 | |
24 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
25 | - $this->object = new \Aimeos\Controller\Frontend\Basket\Decorator\Select( $object, $this->context ); |
|
24 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
25 | + $this->object = new \Aimeos\Controller\Frontend\Basket\Decorator\Select($object, $this->context); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
29 | 29 | protected function tearDown() |
30 | 30 | { |
31 | 31 | $this->object->clear(); |
32 | - $this->context->getSession()->set( 'aimeos', [] ); |
|
32 | + $this->context->getSession()->set('aimeos', []); |
|
33 | 33 | |
34 | - unset( $this->object ); |
|
34 | + unset($this->object); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
38 | 38 | public function testAddDeleteProduct() |
39 | 39 | { |
40 | 40 | $basket = $this->object->get(); |
41 | - $this->object->addProduct( $this->testItem->getId(), 2 ); |
|
41 | + $this->object->addProduct($this->testItem->getId(), 2); |
|
42 | 42 | |
43 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
44 | - $this->assertEquals( 2, $basket->getProduct( 0 )->getQuantity() ); |
|
45 | - $this->assertEquals( 'U:TESTPSUB01', $basket->getProduct( 0 )->getProductCode() ); |
|
43 | + $this->assertEquals(1, count($basket->getProducts())); |
|
44 | + $this->assertEquals(2, $basket->getProduct(0)->getQuantity()); |
|
45 | + $this->assertEquals('U:TESTPSUB01', $basket->getProduct(0)->getProductCode()); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
49 | 49 | public function testAddProductNoSelection() |
50 | 50 | { |
51 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' ); |
|
51 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC'); |
|
52 | 52 | |
53 | - $this->object->addProduct( $item->getId(), 1 ); |
|
53 | + $this->object->addProduct($item->getId(), 1); |
|
54 | 54 | |
55 | - $this->assertEquals( 1, count( $this->object->get()->getProducts() ) ); |
|
56 | - $this->assertEquals( 'CNC', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
57 | - $this->assertEquals( 0, count( $this->object->get()->getProduct( 0 )->getProducts() ) ); |
|
55 | + $this->assertEquals(1, count($this->object->get()->getProducts())); |
|
56 | + $this->assertEquals('CNC', $this->object->get()->getProduct(0)->getProductCode()); |
|
57 | + $this->assertEquals(0, count($this->object->get()->getProduct(0)->getProducts())); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
61 | 61 | public function testAddProductVariant() |
62 | 62 | { |
63 | - $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
63 | + $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
64 | 64 | |
65 | 65 | $search = $attributeManager->createSearch(); |
66 | - $search->setConditions( $search->compare( '==', 'attribute.code', array( 'xs', 'white' ) ) ); |
|
66 | + $search->setConditions($search->compare('==', 'attribute.code', array('xs', 'white'))); |
|
67 | 67 | |
68 | - $attributes = $attributeManager->searchItems( $search ); |
|
68 | + $attributes = $attributeManager->searchItems($search); |
|
69 | 69 | |
70 | - if( count( $attributes ) === 0 ) { |
|
71 | - throw new \RuntimeException( 'Attributes not found' ); |
|
70 | + if (count($attributes) === 0) { |
|
71 | + throw new \RuntimeException('Attributes not found'); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
75 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' ); |
|
75 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC'); |
|
76 | 76 | |
77 | - $this->object->addProduct( $item->getId(), 1, 'default', array_keys( $attributes ), [], [], [] ); |
|
77 | + $this->object->addProduct($item->getId(), 1, 'default', array_keys($attributes), [], [], []); |
|
78 | 78 | |
79 | - $this->assertEquals( 1, count( $this->object->get()->getProducts() ) ); |
|
80 | - $this->assertEquals( 'CNC', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
79 | + $this->assertEquals(1, count($this->object->get()->getProducts())); |
|
80 | + $this->assertEquals('CNC', $this->object->get()->getProduct(0)->getProductCode()); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
84 | 84 | public function testAddProductVariantIncomplete() |
85 | 85 | { |
86 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
86 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
87 | 87 | |
88 | 88 | $search = $attributeManager->createSearch(); |
89 | 89 | $expr = array( |
90 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
91 | - $search->compare( '==', 'attribute.code', '30' ), |
|
92 | - $search->compare( '==', 'attribute.type.code', 'length' ), |
|
90 | + $search->compare('==', 'attribute.domain', 'product'), |
|
91 | + $search->compare('==', 'attribute.code', '30'), |
|
92 | + $search->compare('==', 'attribute.type.code', 'length'), |
|
93 | 93 | ); |
94 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
94 | + $search->setConditions($search->combine('&&', $expr)); |
|
95 | 95 | |
96 | - $attributes = $attributeManager->searchItems( $search ); |
|
96 | + $attributes = $attributeManager->searchItems($search); |
|
97 | 97 | |
98 | - if( count( $attributes ) === 0 ) { |
|
99 | - throw new \RuntimeException( 'Attributes not found' ); |
|
98 | + if (count($attributes) === 0) { |
|
99 | + throw new \RuntimeException('Attributes not found'); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | |
103 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TEST' ); |
|
103 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TEST'); |
|
104 | 104 | |
105 | - $this->object->addProduct( $item->getId(), 1, 'default', array_keys( $attributes ) ); |
|
105 | + $this->object->addProduct($item->getId(), 1, 'default', array_keys($attributes)); |
|
106 | 106 | |
107 | - $this->assertEquals( 1, count( $this->object->get()->getProducts() ) ); |
|
108 | - $this->assertEquals( 'U:TESTSUB02', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
109 | - $this->assertEquals( 2, count( $this->object->get()->getProduct( 0 )->getAttributes() ) ); |
|
107 | + $this->assertEquals(1, count($this->object->get()->getProducts())); |
|
108 | + $this->assertEquals('U:TESTSUB02', $this->object->get()->getProduct(0)->getProductCode()); |
|
109 | + $this->assertEquals(2, count($this->object->get()->getProduct(0)->getAttributes())); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
113 | 113 | public function testAddProductVariantNonUnique() |
114 | 114 | { |
115 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
115 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
116 | 116 | |
117 | 117 | $search = $attributeManager->createSearch(); |
118 | 118 | $expr = array( |
119 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
120 | - $search->compare( '==', 'attribute.code', '30' ), |
|
121 | - $search->compare( '==', 'attribute.type.code', 'width' ), |
|
119 | + $search->compare('==', 'attribute.domain', 'product'), |
|
120 | + $search->compare('==', 'attribute.code', '30'), |
|
121 | + $search->compare('==', 'attribute.type.code', 'width'), |
|
122 | 122 | ); |
123 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
123 | + $search->setConditions($search->combine('&&', $expr)); |
|
124 | 124 | |
125 | - $attributes = $attributeManager->searchItems( $search ); |
|
125 | + $attributes = $attributeManager->searchItems($search); |
|
126 | 126 | |
127 | - if( count( $attributes ) === 0 ) { |
|
128 | - throw new \RuntimeException( 'Attributes not found' ); |
|
127 | + if (count($attributes) === 0) { |
|
128 | + throw new \RuntimeException('Attributes not found'); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
132 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TEST' ); |
|
132 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TEST'); |
|
133 | 133 | |
134 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
135 | - $this->object->addProduct( $item->getId(), 1, 'default', array_keys( $attributes ) ); |
|
134 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
135 | + $this->object->addProduct($item->getId(), 1, 'default', array_keys($attributes)); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
139 | 139 | public function testAddProductVariantNotRequired() |
140 | 140 | { |
141 | - $this->context->getConfig()->set( 'controller/frontend/basket/require-variant', false ); |
|
141 | + $this->context->getConfig()->set('controller/frontend/basket/require-variant', false); |
|
142 | 142 | |
143 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
143 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
144 | 144 | |
145 | 145 | $search = $attributeManager->createSearch(); |
146 | - $search->setConditions( $search->compare( '==', 'attribute.code', 'xs' ) ); |
|
146 | + $search->setConditions($search->compare('==', 'attribute.code', 'xs')); |
|
147 | 147 | |
148 | - $attributes = $attributeManager->searchItems( $search ); |
|
148 | + $attributes = $attributeManager->searchItems($search); |
|
149 | 149 | |
150 | - if( count( $attributes ) === 0 ) { |
|
151 | - throw new \RuntimeException( 'Attribute not found' ); |
|
150 | + if (count($attributes) === 0) { |
|
151 | + throw new \RuntimeException('Attribute not found'); |
|
152 | 152 | } |
153 | 153 | |
154 | - $options = array( 'variant' => false ); |
|
154 | + $options = array('variant' => false); |
|
155 | 155 | |
156 | - $this->object->addProduct( $this->testItem->getId(), 1, 'default', array_keys( $attributes ) ); |
|
156 | + $this->object->addProduct($this->testItem->getId(), 1, 'default', array_keys($attributes)); |
|
157 | 157 | |
158 | - $this->assertEquals( 1, count( $this->object->get()->getProducts() ) ); |
|
159 | - $this->assertEquals( 'U:TESTP', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
158 | + $this->assertEquals(1, count($this->object->get()->getProducts())); |
|
159 | + $this->assertEquals('U:TESTP', $this->object->get()->getProduct(0)->getProductCode()); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
163 | 163 | public function testAddProductEmptySelectionException() |
164 | 164 | { |
165 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:noSel' ); |
|
165 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:noSel'); |
|
166 | 166 | |
167 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
168 | - $this->object->addProduct( $item->getId(), 1 ); |
|
167 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
168 | + $this->object->addProduct($item->getId(), 1); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | |
172 | 172 | public function testAddProductSelectionWithPricelessItem() |
173 | 173 | { |
174 | - $this->object->addProduct( $this->testItem->getId(), 1 ); |
|
174 | + $this->object->addProduct($this->testItem->getId(), 1); |
|
175 | 175 | |
176 | - $this->assertEquals( 'U:TESTPSUB01', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
176 | + $this->assertEquals('U:TESTPSUB01', $this->object->get()->getProduct(0)->getProductCode()); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | |
180 | 180 | public function testAddProductConfigAttribute() |
181 | 181 | { |
182 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
182 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
183 | 183 | |
184 | 184 | $search = $attributeManager->createSearch(); |
185 | - $search->setConditions( $search->compare( '==', 'attribute.code', 'xs' ) ); |
|
185 | + $search->setConditions($search->compare('==', 'attribute.code', 'xs')); |
|
186 | 186 | |
187 | - $attributes = $attributeManager->searchItems( $search ); |
|
187 | + $attributes = $attributeManager->searchItems($search); |
|
188 | 188 | |
189 | - if( ( $attribute = reset( $attributes ) ) === false ) { |
|
190 | - throw new \RuntimeException( 'Attribute not found' ); |
|
189 | + if (($attribute = reset($attributes)) === false) { |
|
190 | + throw new \RuntimeException('Attribute not found'); |
|
191 | 191 | } |
192 | 192 | |
193 | - $this->object->addProduct( $this->testItem->getId(), 1, 'default', [], [$attribute->getId() => 1] ); |
|
193 | + $this->object->addProduct($this->testItem->getId(), 1, 'default', [], [$attribute->getId() => 1]); |
|
194 | 194 | $basket = $this->object->get(); |
195 | 195 | |
196 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
197 | - $this->assertEquals( 'U:TESTPSUB01', $basket->getProduct( 0 )->getProductCode() ); |
|
198 | - $this->assertEquals( 'xs', $basket->getProduct( 0 )->getAttribute( 'size', 'config' ) ); |
|
196 | + $this->assertEquals(1, count($basket->getProducts())); |
|
197 | + $this->assertEquals('U:TESTPSUB01', $basket->getProduct(0)->getProductCode()); |
|
198 | + $this->assertEquals('xs', $basket->getProduct(0)->getAttribute('size', 'config')); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | |
202 | 202 | public function testAddProductHiddenAttribute() |
203 | 203 | { |
204 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
204 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
205 | 205 | |
206 | 206 | $search = $attributeManager->createSearch(); |
207 | 207 | $expr = array( |
208 | - $search->compare( '==', 'attribute.code', '29' ), |
|
209 | - $search->compare( '==', 'attribute.type.code', 'width' ), |
|
208 | + $search->compare('==', 'attribute.code', '29'), |
|
209 | + $search->compare('==', 'attribute.type.code', 'width'), |
|
210 | 210 | ); |
211 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
211 | + $search->setConditions($search->combine('&&', $expr)); |
|
212 | 212 | |
213 | - $attributes = $attributeManager->searchItems( $search ); |
|
213 | + $attributes = $attributeManager->searchItems($search); |
|
214 | 214 | |
215 | - if( empty( $attributes ) ) { |
|
216 | - throw new \RuntimeException( 'Attribute not found' ); |
|
215 | + if (empty($attributes)) { |
|
216 | + throw new \RuntimeException('Attribute not found'); |
|
217 | 217 | } |
218 | 218 | |
219 | - $this->object->addProduct( $this->testItem->getId(), 1, 'default', [], [], array_keys( $attributes ) ); |
|
219 | + $this->object->addProduct($this->testItem->getId(), 1, 'default', [], [], array_keys($attributes)); |
|
220 | 220 | |
221 | 221 | $basket = $this->object->get(); |
222 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
222 | + $this->assertEquals(1, count($basket->getProducts())); |
|
223 | 223 | |
224 | - $product = $basket->getProduct( 0 ); |
|
225 | - $this->assertEquals( 'U:TESTPSUB01', $product->getProductCode() ); |
|
224 | + $product = $basket->getProduct(0); |
|
225 | + $this->assertEquals('U:TESTPSUB01', $product->getProductCode()); |
|
226 | 226 | |
227 | 227 | $attributes = $product->getAttributes(); |
228 | - $this->assertEquals( 1, count( $attributes ) ); |
|
228 | + $this->assertEquals(1, count($attributes)); |
|
229 | 229 | |
230 | - if( ( $attribute = reset( $attributes ) ) === false ) { |
|
231 | - throw new \RuntimeException( 'No attribute' ); |
|
230 | + if (($attribute = reset($attributes)) === false) { |
|
231 | + throw new \RuntimeException('No attribute'); |
|
232 | 232 | } |
233 | 233 | |
234 | - $this->assertEquals( 'hidden', $attribute->getType() ); |
|
235 | - $this->assertEquals( '29', $product->getAttribute( 'width', 'hidden' ) ); |
|
234 | + $this->assertEquals('hidden', $attribute->getType()); |
|
235 | + $this->assertEquals('29', $product->getAttribute('width', 'hidden')); |
|
236 | 236 | } |
237 | 237 | } |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | * @param \Aimeos\MShop\Context\Item\Iface $context Object storing the required instances for manaing databases |
34 | 34 | * connections, logger, session, etc. |
35 | 35 | */ |
36 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
|
36 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context) |
|
37 | 37 | { |
38 | - parent::__construct( $context ); |
|
38 | + parent::__construct($context); |
|
39 | 39 | |
40 | - $this->domainManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
40 | + $this->domainManager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | public function clear() |
50 | 50 | { |
51 | 51 | $this->baskets[$this->type] = $this->domainManager->createItem(); |
52 | - $this->domainManager->setSession( $this->baskets[$this->type], $this->type ); |
|
52 | + $this->domainManager->setSession($this->baskets[$this->type], $this->type); |
|
53 | 53 | |
54 | 54 | return $this; |
55 | 55 | } |
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function get() |
64 | 64 | { |
65 | - if( !isset( $this->baskets[$this->type] ) ) |
|
65 | + if (!isset($this->baskets[$this->type])) |
|
66 | 66 | { |
67 | - $this->baskets[$this->type] = $this->domainManager->getSession( $this->type ); |
|
68 | - $this->checkLocale( $this->type ); |
|
67 | + $this->baskets[$this->type] = $this->domainManager->getSession($this->type); |
|
68 | + $this->checkLocale($this->type); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | return $this->baskets[$this->type]; |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function save() |
81 | 81 | { |
82 | - if( isset( $this->baskets[$this->type] ) && $this->baskets[$this->type]->isModified() ) { |
|
83 | - $this->domainManager->setSession( $this->baskets[$this->type], $this->type ); |
|
82 | + if (isset($this->baskets[$this->type]) && $this->baskets[$this->type]->isModified()) { |
|
83 | + $this->domainManager->setSession($this->baskets[$this->type], $this->type); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | return $this; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param string $type Basket type |
94 | 94 | * @return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object |
95 | 95 | */ |
96 | - public function setType( $type ) |
|
96 | + public function setType($type) |
|
97 | 97 | { |
98 | 98 | $this->type = $type; |
99 | 99 | return $this; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @category Developer |
128 | 128 | * @see controller/frontend/basket/limit-seconds |
129 | 129 | */ |
130 | - $count = $config->get( 'controller/frontend/basket/limit-count', 5 ); |
|
130 | + $count = $config->get('controller/frontend/basket/limit-count', 5); |
|
131 | 131 | |
132 | 132 | /** controller/frontend/basket/limit-seconds |
133 | 133 | * Order limitation time frame in seconds |
@@ -145,30 +145,30 @@ discard block |
||
145 | 145 | * @category Developer |
146 | 146 | * @see controller/frontend/basket/limit-count |
147 | 147 | */ |
148 | - $seconds = $config->get( 'controller/frontend/basket/limit-seconds', 300 ); |
|
148 | + $seconds = $config->get('controller/frontend/basket/limit-seconds', 300); |
|
149 | 149 | |
150 | 150 | $search = $this->domainManager->createSearch(); |
151 | 151 | $expr = [ |
152 | - $search->compare( '==', 'order.base.editor', $context->getEditor() ), |
|
153 | - $search->compare( '>=', 'order.base.ctime', date( 'Y-m-d H:i:s', time() - $seconds ) ), |
|
152 | + $search->compare('==', 'order.base.editor', $context->getEditor()), |
|
153 | + $search->compare('>=', 'order.base.ctime', date('Y-m-d H:i:s', time() - $seconds)), |
|
154 | 154 | ]; |
155 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
156 | - $search->setSlice( 0, 0 ); |
|
155 | + $search->setConditions($search->combine('&&', $expr)); |
|
156 | + $search->setSlice(0, 0); |
|
157 | 157 | |
158 | - $this->domainManager->searchItems( $search, [], $total ); |
|
158 | + $this->domainManager->searchItems($search, [], $total); |
|
159 | 159 | |
160 | - if( $total > $count ) |
|
160 | + if ($total > $count) |
|
161 | 161 | { |
162 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Temporary order limit reached' ); |
|
163 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
162 | + $msg = $context->getI18n()->dt('controller/frontend', 'Temporary order limit reached'); |
|
163 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
167 | 167 | $basket = $this->get()->finish(); |
168 | - $basket->setCustomerId( (string) $context->getUserId() ); |
|
168 | + $basket->setCustomerId((string) $context->getUserId()); |
|
169 | 169 | |
170 | 170 | $this->domainManager->begin(); |
171 | - $this->domainManager->store( $basket ); |
|
171 | + $this->domainManager->store($basket); |
|
172 | 172 | $this->domainManager->commit(); |
173 | 173 | |
174 | 174 | return $basket; |
@@ -183,9 +183,9 @@ discard block |
||
183 | 183 | * @param boolean $default True to add default criteria (user logged in), false if not |
184 | 184 | * @return \Aimeos\MShop\Order\Item\Base\Iface Order base object including the given parts |
185 | 185 | */ |
186 | - public function load( $id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true ) |
|
186 | + public function load($id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true) |
|
187 | 187 | { |
188 | - return $this->domainManager->load( $id, $parts, false, $default ); |
|
188 | + return $this->domainManager->load($id, $parts, false, $default); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | |
@@ -204,33 +204,33 @@ discard block |
||
204 | 204 | * @param string $stocktype Unique code of the stock type to deliver the products from |
205 | 205 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
206 | 206 | */ |
207 | - public function addProduct( $prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
208 | - array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [] ) |
|
207 | + public function addProduct($prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
208 | + array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = []) |
|
209 | 209 | { |
210 | 210 | $attributeMap = [ |
211 | - 'custom' => array_keys( $customAttributeValues ), |
|
212 | - 'config' => array_keys( $configAttributeIds ), |
|
211 | + 'custom' => array_keys($customAttributeValues), |
|
212 | + 'config' => array_keys($configAttributeIds), |
|
213 | 213 | 'hidden' => $hiddenAttributeIds, |
214 | 214 | ]; |
215 | - $this->checkListRef( $prodid, 'attribute', $attributeMap ); |
|
215 | + $this->checkListRef($prodid, 'attribute', $attributeMap); |
|
216 | 216 | |
217 | 217 | |
218 | 218 | $context = $this->getContext(); |
219 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
220 | - $productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ), true ); |
|
221 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
219 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
220 | + $productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'), true); |
|
221 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
222 | 222 | |
223 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
224 | - $orderBaseProductItem->copyFrom( $productItem )->setQuantity( $quantity )->setStockType( $stocktype ); |
|
223 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
224 | + $orderBaseProductItem->copyFrom($productItem)->setQuantity($quantity)->setStockType($stocktype); |
|
225 | 225 | |
226 | - $attr = $this->getOrderProductAttributes( 'custom', array_keys( $customAttributeValues ), $customAttributeValues ); |
|
227 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'config', array_keys( $configAttributeIds ), [], $configAttributeIds ) ); |
|
228 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'hidden', $hiddenAttributeIds ) ); |
|
226 | + $attr = $this->getOrderProductAttributes('custom', array_keys($customAttributeValues), $customAttributeValues); |
|
227 | + $attr = array_merge($attr, $this->getOrderProductAttributes('config', array_keys($configAttributeIds), [], $configAttributeIds)); |
|
228 | + $attr = array_merge($attr, $this->getOrderProductAttributes('hidden', $hiddenAttributeIds)); |
|
229 | 229 | |
230 | - $orderBaseProductItem->setAttributes( $attr ); |
|
231 | - $orderBaseProductItem->setPrice( $this->calcPrice( $orderBaseProductItem, $prices, $quantity ) ); |
|
230 | + $orderBaseProductItem->setAttributes($attr); |
|
231 | + $orderBaseProductItem->setPrice($this->calcPrice($orderBaseProductItem, $prices, $quantity)); |
|
232 | 232 | |
233 | - $this->get()->addProduct( $orderBaseProductItem ); |
|
233 | + $this->get()->addProduct($orderBaseProductItem); |
|
234 | 234 | $this->save(); |
235 | 235 | } |
236 | 236 | |
@@ -240,17 +240,17 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @param integer $position Position number (key) of the order product item |
242 | 242 | */ |
243 | - public function deleteProduct( $position ) |
|
243 | + public function deleteProduct($position) |
|
244 | 244 | { |
245 | - $product = $this->get()->getProduct( $position ); |
|
245 | + $product = $this->get()->getProduct($position); |
|
246 | 246 | |
247 | - if( $product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
247 | + if ($product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
248 | 248 | { |
249 | - $msg = $this->getContext()->getI18n()->dt( 'controller/frontend', 'Basket item at position "%1$d" cannot be deleted manually' ); |
|
250 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $position ) ); |
|
249 | + $msg = $this->getContext()->getI18n()->dt('controller/frontend', 'Basket item at position "%1$d" cannot be deleted manually'); |
|
250 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $position)); |
|
251 | 251 | } |
252 | 252 | |
253 | - $this->get()->deleteProduct( $position ); |
|
253 | + $this->get()->deleteProduct($position); |
|
254 | 254 | $this->save(); |
255 | 255 | } |
256 | 256 | |
@@ -262,32 +262,32 @@ discard block |
||
262 | 262 | * @param integer $quantity New quantiy of the product item |
263 | 263 | * @param string[] $configAttributeCodes Codes of the product config attributes that should be REMOVED |
264 | 264 | */ |
265 | - public function editProduct( $position, $quantity, array $configAttributeCodes = [] ) |
|
265 | + public function editProduct($position, $quantity, array $configAttributeCodes = []) |
|
266 | 266 | { |
267 | - $product = $this->get()->getProduct( $position ); |
|
267 | + $product = $this->get()->getProduct($position); |
|
268 | 268 | |
269 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
269 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
270 | 270 | { |
271 | - $msg = $this->getContext()->getI18n()->dt( 'controller/frontend', 'Basket item at position "%1$d" cannot be changed' ); |
|
272 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $position ) ); |
|
271 | + $msg = $this->getContext()->getI18n()->dt('controller/frontend', 'Basket item at position "%1$d" cannot be changed'); |
|
272 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $position)); |
|
273 | 273 | } |
274 | 274 | |
275 | - $product->setQuantity( $quantity ); |
|
275 | + $product->setQuantity($quantity); |
|
276 | 276 | |
277 | 277 | $attributes = $product->getAttributes(); |
278 | - foreach( $attributes as $key => $attribute ) |
|
278 | + foreach ($attributes as $key => $attribute) |
|
279 | 279 | { |
280 | - if( in_array( $attribute->getCode(), $configAttributeCodes ) ) { |
|
281 | - unset( $attributes[$key] ); |
|
280 | + if (in_array($attribute->getCode(), $configAttributeCodes)) { |
|
281 | + unset($attributes[$key]); |
|
282 | 282 | } |
283 | 283 | } |
284 | - $product->setAttributes( $attributes ); |
|
284 | + $product->setAttributes($attributes); |
|
285 | 285 | |
286 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
287 | - $productItem = $manager->findItem( $product->getProductCode(), array( 'price', 'text' ) ); |
|
288 | - $product->setPrice( $this->calcPrice( $product, $productItem->getRefItems( 'price', 'default' ), $quantity ) ); |
|
286 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
287 | + $productItem = $manager->findItem($product->getProductCode(), array('price', 'text')); |
|
288 | + $product->setPrice($this->calcPrice($product, $productItem->getRefItems('price', 'default'), $quantity)); |
|
289 | 289 | |
290 | - $this->get()->editProduct( $product, $position ); |
|
290 | + $this->get()->editProduct($product, $position); |
|
291 | 291 | |
292 | 292 | $this->save(); |
293 | 293 | } |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @param string $code Coupon code entered by the user |
300 | 300 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
301 | 301 | */ |
302 | - public function addCoupon( $code ) |
|
302 | + public function addCoupon($code) |
|
303 | 303 | { |
304 | 304 | $context = $this->getContext(); |
305 | 305 | |
@@ -319,63 +319,63 @@ discard block |
||
319 | 319 | * @category User |
320 | 320 | * @category Developer |
321 | 321 | */ |
322 | - $allowed = $context->getConfig()->get( 'client/html/basket/standard/coupon/allowed', 1 ); // @deprecated |
|
323 | - $allowed = $context->getConfig()->get( 'controller/frontend/basket/standard/coupon/allowed', $allowed ); |
|
322 | + $allowed = $context->getConfig()->get('client/html/basket/standard/coupon/allowed', 1); // @deprecated |
|
323 | + $allowed = $context->getConfig()->get('controller/frontend/basket/standard/coupon/allowed', $allowed); |
|
324 | 324 | |
325 | - if( $allowed <= count( $this->get()->getCoupons() ) ) |
|
325 | + if ($allowed <= count($this->get()->getCoupons())) |
|
326 | 326 | { |
327 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Number of coupon codes exceeds the limit' ); |
|
328 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
327 | + $msg = $context->getI18n()->dt('controller/frontend', 'Number of coupon codes exceeds the limit'); |
|
328 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | |
332 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
333 | - $codeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon/code' ); |
|
332 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
333 | + $codeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon/code'); |
|
334 | 334 | |
335 | 335 | |
336 | - $search = $codeManager->createSearch( true ); |
|
336 | + $search = $codeManager->createSearch(true); |
|
337 | 337 | $expr = array( |
338 | - $search->compare( '==', 'coupon.code.code', $code ), |
|
338 | + $search->compare('==', 'coupon.code.code', $code), |
|
339 | 339 | $search->getConditions(), |
340 | 340 | ); |
341 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
342 | - $search->setSlice( 0, 1 ); |
|
341 | + $search->setConditions($search->combine('&&', $expr)); |
|
342 | + $search->setSlice(0, 1); |
|
343 | 343 | |
344 | - $result = $codeManager->searchItems( $search ); |
|
344 | + $result = $codeManager->searchItems($search); |
|
345 | 345 | |
346 | - if( ( $codeItem = reset( $result ) ) === false ) |
|
346 | + if (($codeItem = reset($result)) === false) |
|
347 | 347 | { |
348 | - $msg = sprintf( $context->getI18n()->dt( 'controller/frontend', 'Coupon code "%1$s" is invalid or not available any more' ), $code ); |
|
349 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
348 | + $msg = sprintf($context->getI18n()->dt('controller/frontend', 'Coupon code "%1$s" is invalid or not available any more'), $code); |
|
349 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | |
353 | - $search = $manager->createSearch( true ); |
|
353 | + $search = $manager->createSearch(true); |
|
354 | 354 | $expr = array( |
355 | - $search->compare( '==', 'coupon.id', $codeItem->getParentId() ), |
|
355 | + $search->compare('==', 'coupon.id', $codeItem->getParentId()), |
|
356 | 356 | $search->getConditions(), |
357 | 357 | ); |
358 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
359 | - $search->setSlice( 0, 1 ); |
|
358 | + $search->setConditions($search->combine('&&', $expr)); |
|
359 | + $search->setSlice(0, 1); |
|
360 | 360 | |
361 | - $result = $manager->searchItems( $search ); |
|
361 | + $result = $manager->searchItems($search); |
|
362 | 362 | |
363 | - if( ( $item = reset( $result ) ) === false ) |
|
363 | + if (($item = reset($result)) === false) |
|
364 | 364 | { |
365 | - $msg = sprintf( $context->getI18n()->dt( 'controller/frontend', 'Coupon for code "%1$s" is not available any more' ), $code ); |
|
366 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
365 | + $msg = sprintf($context->getI18n()->dt('controller/frontend', 'Coupon for code "%1$s" is not available any more'), $code); |
|
366 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | |
370 | - $provider = $manager->getProvider( $item, $codeItem->getCode() ); |
|
370 | + $provider = $manager->getProvider($item, $codeItem->getCode()); |
|
371 | 371 | |
372 | - if( $provider->isAvailable( $this->get() ) !== true ) |
|
372 | + if ($provider->isAvailable($this->get()) !== true) |
|
373 | 373 | { |
374 | - $msg = sprintf( $context->getI18n()->dt( 'controller/frontend', 'Requirements for coupon code "%1$s" aren\'t met' ), $code ); |
|
375 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
374 | + $msg = sprintf($context->getI18n()->dt('controller/frontend', 'Requirements for coupon code "%1$s" aren\'t met'), $code); |
|
375 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
376 | 376 | } |
377 | 377 | |
378 | - $provider->addCoupon( $this->get() ); |
|
378 | + $provider->addCoupon($this->get()); |
|
379 | 379 | $this->save(); |
380 | 380 | } |
381 | 381 | |
@@ -386,24 +386,24 @@ discard block |
||
386 | 386 | * @param string $code Coupon code entered by the user |
387 | 387 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
388 | 388 | */ |
389 | - public function deleteCoupon( $code ) |
|
389 | + public function deleteCoupon($code) |
|
390 | 390 | { |
391 | 391 | $context = $this->getContext(); |
392 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'coupon' ); |
|
392 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'coupon'); |
|
393 | 393 | |
394 | 394 | $search = $manager->createSearch(); |
395 | - $search->setConditions( $search->compare( '==', 'coupon.code.code', $code ) ); |
|
396 | - $search->setSlice( 0, 1 ); |
|
395 | + $search->setConditions($search->compare('==', 'coupon.code.code', $code)); |
|
396 | + $search->setSlice(0, 1); |
|
397 | 397 | |
398 | - $result = $manager->searchItems( $search ); |
|
398 | + $result = $manager->searchItems($search); |
|
399 | 399 | |
400 | - if( ( $item = reset( $result ) ) === false ) |
|
400 | + if (($item = reset($result)) === false) |
|
401 | 401 | { |
402 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Coupon code "%1$s" is invalid' ); |
|
403 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $code ) ); |
|
402 | + $msg = $context->getI18n()->dt('controller/frontend', 'Coupon code "%1$s" is invalid'); |
|
403 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $code)); |
|
404 | 404 | } |
405 | 405 | |
406 | - $manager->getProvider( $item, $code )->deleteCoupon( $this->get() ); |
|
406 | + $manager->getProvider($item, $code)->deleteCoupon($this->get()); |
|
407 | 407 | $this->save(); |
408 | 408 | } |
409 | 409 | |
@@ -416,30 +416,30 @@ discard block |
||
416 | 416 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the billing or delivery address is not of any required type of |
417 | 417 | * if one of the keys is invalid when using an array with key/value pairs |
418 | 418 | */ |
419 | - public function setAddress( $type, $value ) |
|
419 | + public function setAddress($type, $value) |
|
420 | 420 | { |
421 | 421 | $context = $this->getContext(); |
422 | - $address = \Aimeos\MShop\Factory::createManager( $context, 'order/base/address' )->createItem(); |
|
423 | - $address->setType( $type ); |
|
422 | + $address = \Aimeos\MShop\Factory::createManager($context, 'order/base/address')->createItem(); |
|
423 | + $address->setType($type); |
|
424 | 424 | |
425 | - if( $value instanceof \Aimeos\MShop\Common\Item\Address\Iface ) |
|
425 | + if ($value instanceof \Aimeos\MShop\Common\Item\Address\Iface) |
|
426 | 426 | { |
427 | - $address->copyFrom( $value ); |
|
428 | - $this->get()->setAddress( $address, $type ); |
|
427 | + $address->copyFrom($value); |
|
428 | + $this->get()->setAddress($address, $type); |
|
429 | 429 | } |
430 | - else if( is_array( $value ) ) |
|
430 | + else if (is_array($value)) |
|
431 | 431 | { |
432 | - $this->setAddressFromArray( $address, $value ); |
|
433 | - $this->get()->setAddress( $address, $type ); |
|
432 | + $this->setAddressFromArray($address, $value); |
|
433 | + $this->get()->setAddress($address, $type); |
|
434 | 434 | } |
435 | - else if( $value === null ) |
|
435 | + else if ($value === null) |
|
436 | 436 | { |
437 | - $this->get()->deleteAddress( $type ); |
|
437 | + $this->get()->deleteAddress($type); |
|
438 | 438 | } |
439 | 439 | else |
440 | 440 | { |
441 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Invalid value for address type "%1$s"' ); |
|
442 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $type ) ); |
|
441 | + $msg = $context->getI18n()->dt('controller/frontend', 'Invalid value for address type "%1$s"'); |
|
442 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $type)); |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | $this->save(); |
@@ -455,42 +455,42 @@ discard block |
||
455 | 455 | * entered by the customer when choosing one of the delivery or payment options |
456 | 456 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
457 | 457 | */ |
458 | - public function addService( $type, $id, array $attributes = [] ) |
|
458 | + public function addService($type, $id, array $attributes = []) |
|
459 | 459 | { |
460 | 460 | $context = $this->getContext(); |
461 | 461 | |
462 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $context, 'service' ); |
|
463 | - $serviceItem = $serviceManager->getItem( $id, array( 'media', 'price', 'text' ) ); |
|
462 | + $serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service'); |
|
463 | + $serviceItem = $serviceManager->getItem($id, array('media', 'price', 'text')); |
|
464 | 464 | |
465 | - $provider = $serviceManager->getProvider( $serviceItem ); |
|
466 | - $result = $provider->checkConfigFE( $attributes ); |
|
467 | - $unknown = array_diff_key( $attributes, $result ); |
|
465 | + $provider = $serviceManager->getProvider($serviceItem); |
|
466 | + $result = $provider->checkConfigFE($attributes); |
|
467 | + $unknown = array_diff_key($attributes, $result); |
|
468 | 468 | |
469 | - if( count( $unknown ) > 0 ) |
|
469 | + if (count($unknown) > 0) |
|
470 | 470 | { |
471 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Unknown attributes "%1$s"' ); |
|
472 | - $msg = sprintf( $msg, implode( '","', array_keys( $unknown ) ) ); |
|
473 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
471 | + $msg = $context->getI18n()->dt('controller/frontend', 'Unknown attributes "%1$s"'); |
|
472 | + $msg = sprintf($msg, implode('","', array_keys($unknown))); |
|
473 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
474 | 474 | } |
475 | 475 | |
476 | - foreach( $result as $key => $value ) |
|
476 | + foreach ($result as $key => $value) |
|
477 | 477 | { |
478 | - if( $value !== null ) { |
|
479 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $value ); |
|
478 | + if ($value !== null) { |
|
479 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($value); |
|
480 | 480 | } |
481 | 481 | } |
482 | 482 | |
483 | - $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/service' ); |
|
483 | + $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/service'); |
|
484 | 484 | $orderServiceItem = $orderBaseServiceManager->createItem(); |
485 | - $orderServiceItem->copyFrom( $serviceItem ); |
|
485 | + $orderServiceItem->copyFrom($serviceItem); |
|
486 | 486 | |
487 | 487 | // remove service rebate of original price |
488 | - $price = $provider->calcPrice( $this->get() )->setRebate( '0.00' ); |
|
489 | - $orderServiceItem->setPrice( $price ); |
|
488 | + $price = $provider->calcPrice($this->get())->setRebate('0.00'); |
|
489 | + $orderServiceItem->setPrice($price); |
|
490 | 490 | |
491 | - $provider->setConfigFE( $orderServiceItem, $attributes ); |
|
491 | + $provider->setConfigFE($orderServiceItem, $attributes); |
|
492 | 492 | |
493 | - $this->get()->addService( $orderServiceItem, $type ); |
|
493 | + $this->get()->addService($orderServiceItem, $type); |
|
494 | 494 | $this->save(); |
495 | 495 | } |
496 | 496 | |
@@ -500,9 +500,9 @@ discard block |
||
500 | 500 | * |
501 | 501 | * @param string $type Service type code like 'payment' or 'delivery' |
502 | 502 | */ |
503 | - public function deleteService( $type ) |
|
503 | + public function deleteService($type) |
|
504 | 504 | { |
505 | - $this->get()->deleteService( $type ); |
|
505 | + $this->get()->deleteService($type); |
|
506 | 506 | $this->save(); |
507 | 507 | } |
508 | 508 | |
@@ -515,18 +515,18 @@ discard block |
||
515 | 515 | * an address item. |
516 | 516 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
517 | 517 | */ |
518 | - protected function setAddressFromArray( \Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map ) |
|
518 | + protected function setAddressFromArray(\Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map) |
|
519 | 519 | { |
520 | - foreach( $map as $key => $value ) { |
|
521 | - $map[$key] = strip_tags( $value ); // prevent XSS |
|
520 | + foreach ($map as $key => $value) { |
|
521 | + $map[$key] = strip_tags($value); // prevent XSS |
|
522 | 522 | } |
523 | 523 | |
524 | - $errors = $address->fromArray( $map ); |
|
524 | + $errors = $address->fromArray($map); |
|
525 | 525 | |
526 | - if( count( $errors ) > 0 ) |
|
526 | + if (count($errors) > 0) |
|
527 | 527 | { |
528 | - $msg = $this->getContext()->getI18n()->dt( 'controller/frontend', 'Invalid address properties, please check your input' ); |
|
529 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg, 0, null, $errors ); |
|
528 | + $msg = $this->getContext()->getI18n()->dt('controller/frontend', 'Invalid address properties, please check your input'); |
|
529 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg, 0, null, $errors); |
|
530 | 530 | } |
531 | 531 | } |
532 | 532 | } |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | * @param string $stocktype Unique code of the stock type to deliver the products from |
37 | 37 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
38 | 38 | */ |
39 | - public function addProduct( $prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
40 | - array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [] ) |
|
39 | + public function addProduct($prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
40 | + array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = []) |
|
41 | 41 | { |
42 | 42 | $context = $this->getContext(); |
43 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
43 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
44 | 44 | |
45 | - if( $productManager->getItem( $prodid, [], true )->getType() !== 'bundle' ) |
|
45 | + if ($productManager->getItem($prodid, [], true)->getType() !== 'bundle') |
|
46 | 46 | { |
47 | 47 | return $this->getController()->addProduct( |
48 | 48 | $prodid, $quantity, $stocktype, $variantAttributeIds, |
@@ -51,29 +51,29 @@ discard block |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | $attributeMap = [ |
54 | - 'custom' => array_keys( $customAttributeValues ), |
|
55 | - 'config' => array_keys( $configAttributeIds ), |
|
54 | + 'custom' => array_keys($customAttributeValues), |
|
55 | + 'config' => array_keys($configAttributeIds), |
|
56 | 56 | 'hidden' => $hiddenAttributeIds, |
57 | 57 | ]; |
58 | - $this->checkListRef( $prodid, 'attribute', $attributeMap ); |
|
58 | + $this->checkListRef($prodid, 'attribute', $attributeMap); |
|
59 | 59 | |
60 | 60 | |
61 | - $productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ), true ); |
|
62 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
61 | + $productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'), true); |
|
62 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
63 | 63 | |
64 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
65 | - $orderBaseProductItem->copyFrom( $productItem )->setQuantity( $quantity )->setStockType( $stocktype ); |
|
64 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
65 | + $orderBaseProductItem->copyFrom($productItem)->setQuantity($quantity)->setStockType($stocktype); |
|
66 | 66 | |
67 | - $this->addBundleProducts( $orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype ); |
|
67 | + $this->addBundleProducts($orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype); |
|
68 | 68 | |
69 | - $attr = $this->getOrderProductAttributes( 'custom', array_keys( $customAttributeValues ), $customAttributeValues ); |
|
70 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'config', array_keys( $configAttributeIds ), [], $configAttributeIds ) ); |
|
71 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'hidden', $hiddenAttributeIds ) ); |
|
69 | + $attr = $this->getOrderProductAttributes('custom', array_keys($customAttributeValues), $customAttributeValues); |
|
70 | + $attr = array_merge($attr, $this->getOrderProductAttributes('config', array_keys($configAttributeIds), [], $configAttributeIds)); |
|
71 | + $attr = array_merge($attr, $this->getOrderProductAttributes('hidden', $hiddenAttributeIds)); |
|
72 | 72 | |
73 | - $orderBaseProductItem->setAttributes( $attr ); |
|
74 | - $orderBaseProductItem->setPrice( $this->calcPrice( $orderBaseProductItem, $prices, $quantity ) ); |
|
73 | + $orderBaseProductItem->setAttributes($attr); |
|
74 | + $orderBaseProductItem->setPrice($this->calcPrice($orderBaseProductItem, $prices, $quantity)); |
|
75 | 75 | |
76 | - $this->getController()->get()->addProduct( $orderBaseProductItem ); |
|
76 | + $this->getController()->get()->addProduct($orderBaseProductItem); |
|
77 | 77 | $this->getController()->save(); |
78 | 78 | } |
79 | 79 | |
@@ -86,43 +86,43 @@ discard block |
||
86 | 86 | * @param array $variantAttributeIds List of product variant attribute IDs |
87 | 87 | * @param string $stocktype |
88 | 88 | */ |
89 | - protected function addBundleProducts( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
90 | - \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype ) |
|
89 | + protected function addBundleProducts(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
90 | + \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype) |
|
91 | 91 | { |
92 | 92 | $quantity = $orderBaseProductItem->getQuantity(); |
93 | 93 | $products = $subProductIds = $orderProducts = []; |
94 | - $orderProductManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product' ); |
|
94 | + $orderProductManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product'); |
|
95 | 95 | |
96 | - foreach( $productItem->getRefItems( 'product', null, 'default' ) as $item ) { |
|
96 | + foreach ($productItem->getRefItems('product', null, 'default') as $item) { |
|
97 | 97 | $subProductIds[] = $item->getId(); |
98 | 98 | } |
99 | 99 | |
100 | - if( count( $subProductIds ) > 0 ) |
|
100 | + if (count($subProductIds) > 0) |
|
101 | 101 | { |
102 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
102 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
103 | 103 | |
104 | - $search = $productManager->createSearch( true ); |
|
104 | + $search = $productManager->createSearch(true); |
|
105 | 105 | $expr = array( |
106 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
106 | + $search->compare('==', 'product.id', $subProductIds), |
|
107 | 107 | $search->getConditions(), |
108 | 108 | ); |
109 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
109 | + $search->setConditions($search->combine('&&', $expr)); |
|
110 | 110 | |
111 | - $products = $productManager->searchItems( $search, array( 'attribute', 'media', 'price', 'text' ) ); |
|
111 | + $products = $productManager->searchItems($search, array('attribute', 'media', 'price', 'text')); |
|
112 | 112 | } |
113 | 113 | |
114 | - foreach( $products as $product ) |
|
114 | + foreach ($products as $product) |
|
115 | 115 | { |
116 | - $prices = $product->getRefItems( 'price', 'default', 'default' ); |
|
116 | + $prices = $product->getRefItems('price', 'default', 'default'); |
|
117 | 117 | |
118 | 118 | $orderProduct = $orderProductManager->createItem(); |
119 | - $orderProduct->copyFrom( $product ); |
|
120 | - $orderProduct->setStockType( $stocktype ); |
|
121 | - $orderProduct->setPrice( $this->calcPrice( $orderProduct, $prices, $quantity ) ); |
|
119 | + $orderProduct->copyFrom($product); |
|
120 | + $orderProduct->setStockType($stocktype); |
|
121 | + $orderProduct->setPrice($this->calcPrice($orderProduct, $prices, $quantity)); |
|
122 | 122 | |
123 | 123 | $orderProducts[] = $orderProduct; |
124 | 124 | } |
125 | 125 | |
126 | - $orderBaseProductItem->setProducts( $orderProducts ); |
|
126 | + $orderBaseProductItem->setProducts($orderProducts); |
|
127 | 127 | } |
128 | 128 | } |
@@ -36,26 +36,26 @@ |
||
36 | 36 | * @param string $stocktype Unique code of the stock type to deliver the products from |
37 | 37 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
38 | 38 | */ |
39 | - public function addProduct( $prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
40 | - array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [] ) |
|
39 | + public function addProduct($prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
40 | + array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = []) |
|
41 | 41 | { |
42 | - $catalogListManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' ); |
|
42 | + $catalogListManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists'); |
|
43 | 43 | |
44 | - $search = $catalogListManager->createSearch( true ); |
|
44 | + $search = $catalogListManager->createSearch(true); |
|
45 | 45 | $expr = array( |
46 | - $search->compare( '==', 'catalog.lists.domain', 'product' ), |
|
47 | - $search->compare( '==', 'catalog.lists.refid', $prodid ), |
|
46 | + $search->compare('==', 'catalog.lists.domain', 'product'), |
|
47 | + $search->compare('==', 'catalog.lists.refid', $prodid), |
|
48 | 48 | $search->getConditions() |
49 | 49 | ); |
50 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
51 | - $search->setSlice( 0, 1 ); |
|
50 | + $search->setConditions($search->combine('&&', $expr)); |
|
51 | + $search->setSlice(0, 1); |
|
52 | 52 | |
53 | - $result = $catalogListManager->searchItems( $search ); |
|
53 | + $result = $catalogListManager->searchItems($search); |
|
54 | 54 | |
55 | - if( reset( $result ) === false ) |
|
55 | + if (reset($result) === false) |
|
56 | 56 | { |
57 | - $msg = sprintf( 'Adding product with ID "%1$s" is not allowed', $prodid ); |
|
58 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
57 | + $msg = sprintf('Adding product with ID "%1$s" is not allowed', $prodid); |
|
58 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | $this->getController()->addProduct( |
@@ -36,14 +36,14 @@ discard block |
||
36 | 36 | * @param string $stocktype Unique code of the stock type to deliver the products from |
37 | 37 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
38 | 38 | */ |
39 | - public function addProduct( $prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
40 | - array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [] ) |
|
39 | + public function addProduct($prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
40 | + array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = []) |
|
41 | 41 | { |
42 | 42 | $context = $this->getContext(); |
43 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
44 | - $productItem = $productManager->getItem( $prodid, [], true ); |
|
43 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
44 | + $productItem = $productManager->getItem($prodid, [], true); |
|
45 | 45 | |
46 | - if( $productManager->getItem( $prodid, [], true )->getType() !== 'select' ) |
|
46 | + if ($productManager->getItem($prodid, [], true)->getType() !== 'select') |
|
47 | 47 | { |
48 | 48 | return $this->getController()->addProduct( |
49 | 49 | $prodid, $quantity, $stocktype, $variantAttributeIds, |
@@ -51,29 +51,29 @@ discard block |
||
51 | 51 | ); |
52 | 52 | } |
53 | 53 | |
54 | - $productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ), true ); |
|
55 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
54 | + $productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'), true); |
|
55 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
56 | 56 | |
57 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
58 | - $orderBaseProductItem->copyFrom( $productItem )->setQuantity( $quantity )->setStockType( $stocktype ); |
|
57 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
58 | + $orderBaseProductItem->copyFrom($productItem)->setQuantity($quantity)->setStockType($stocktype); |
|
59 | 59 | |
60 | - $attr = $this->getVariantDetails( $orderBaseProductItem, $productItem, $prices, $variantAttributeIds ); |
|
60 | + $attr = $this->getVariantDetails($orderBaseProductItem, $productItem, $prices, $variantAttributeIds); |
|
61 | 61 | |
62 | 62 | $attributeMap = [ |
63 | - 'custom' => array_keys( $customAttributeValues ), |
|
64 | - 'config' => array_keys( $configAttributeIds ), |
|
63 | + 'custom' => array_keys($customAttributeValues), |
|
64 | + 'config' => array_keys($configAttributeIds), |
|
65 | 65 | 'hidden' => $hiddenAttributeIds, |
66 | 66 | ]; |
67 | - $this->checkListRef( array( $prodid, $productItem->getId() ), 'attribute', $attributeMap ); |
|
67 | + $this->checkListRef(array($prodid, $productItem->getId()), 'attribute', $attributeMap); |
|
68 | 68 | |
69 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'custom', array_keys( $customAttributeValues ), $customAttributeValues ) ); |
|
70 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'config', array_keys( $configAttributeIds ), [], $configAttributeIds ) ); |
|
71 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'hidden', $hiddenAttributeIds ) ); |
|
69 | + $attr = array_merge($attr, $this->getOrderProductAttributes('custom', array_keys($customAttributeValues), $customAttributeValues)); |
|
70 | + $attr = array_merge($attr, $this->getOrderProductAttributes('config', array_keys($configAttributeIds), [], $configAttributeIds)); |
|
71 | + $attr = array_merge($attr, $this->getOrderProductAttributes('hidden', $hiddenAttributeIds)); |
|
72 | 72 | |
73 | - $orderBaseProductItem->setAttributes( $attr ); |
|
74 | - $orderBaseProductItem->setPrice( $this->calcPrice( $orderBaseProductItem, $prices, $quantity ) ); |
|
73 | + $orderBaseProductItem->setAttributes($attr); |
|
74 | + $orderBaseProductItem->setPrice($this->calcPrice($orderBaseProductItem, $prices, $quantity)); |
|
75 | 75 | |
76 | - $this->getController()->get()->addProduct( $orderBaseProductItem ); |
|
76 | + $this->getController()->get()->addProduct($orderBaseProductItem); |
|
77 | 77 | $this->getController()->save(); |
78 | 78 | } |
79 | 79 | |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | * @return \Aimeos\MShop\Order\Item\Base\Product\Attribute\Iface[] List of order product attributes |
89 | 89 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If no product variant is found |
90 | 90 | */ |
91 | - protected function getVariantDetails( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
92 | - \Aimeos\MShop\Product\Item\Iface &$productItem, array &$prices, array $variantAttributeIds ) |
|
91 | + protected function getVariantDetails(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
92 | + \Aimeos\MShop\Product\Item\Iface & $productItem, array &$prices, array $variantAttributeIds) |
|
93 | 93 | { |
94 | 94 | $attr = []; |
95 | 95 | $context = $this->getContext(); |
96 | - $productItems = $this->getProductVariants( $productItem, $variantAttributeIds ); |
|
96 | + $productItems = $this->getProductVariants($productItem, $variantAttributeIds); |
|
97 | 97 | |
98 | 98 | /** controller/frontend/basket/require-variant |
99 | 99 | * A variant of a selection product must be chosen |
@@ -114,47 +114,47 @@ discard block |
||
114 | 114 | * @category Developer |
115 | 115 | * @category User |
116 | 116 | */ |
117 | - $requireVariant = $context->getConfig()->get( 'controller/frontend/basket/require-variant', true ); |
|
117 | + $requireVariant = $context->getConfig()->get('controller/frontend/basket/require-variant', true); |
|
118 | 118 | |
119 | 119 | |
120 | - if( count( $productItems ) > 1 ) |
|
120 | + if (count($productItems) > 1) |
|
121 | 121 | { |
122 | - $msg = sprintf( 'No unique article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
|
123 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
122 | + $msg = sprintf('No unique article found for selected attributes and product ID "%1$s"', $productItem->getId()); |
|
123 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
124 | 124 | } |
125 | - else if( ( $result = reset( $productItems ) ) !== false ) // count == 1 |
|
125 | + else if (($result = reset($productItems)) !== false) // count == 1 |
|
126 | 126 | { |
127 | 127 | $productItem = $result; |
128 | - $orderBaseProductItem->setProductCode( $productItem->getCode() ); |
|
128 | + $orderBaseProductItem->setProductCode($productItem->getCode()); |
|
129 | 129 | |
130 | - $subprices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
130 | + $subprices = $productItem->getRefItems('price', 'default', 'default'); |
|
131 | 131 | |
132 | - if( !empty( $subprices ) ) { |
|
132 | + if (!empty($subprices)) { |
|
133 | 133 | $prices = $subprices; |
134 | 134 | } |
135 | 135 | |
136 | - $submedia = $productItem->getRefItems( 'media', 'default', 'default' ); |
|
136 | + $submedia = $productItem->getRefItems('media', 'default', 'default'); |
|
137 | 137 | |
138 | - if( ( $mediaItem = reset( $submedia ) ) !== false ) { |
|
139 | - $orderBaseProductItem->setMediaUrl( $mediaItem->getPreview() ); |
|
138 | + if (($mediaItem = reset($submedia)) !== false) { |
|
139 | + $orderBaseProductItem->setMediaUrl($mediaItem->getPreview()); |
|
140 | 140 | } |
141 | 141 | |
142 | - $orderProductAttrManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product/attribute' ); |
|
143 | - $variantAttributes = $productItem->getRefItems( 'attribute', null, 'variant' ); |
|
142 | + $orderProductAttrManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product/attribute'); |
|
143 | + $variantAttributes = $productItem->getRefItems('attribute', null, 'variant'); |
|
144 | 144 | |
145 | - foreach( $this->getAttributes( array_keys( $variantAttributes ), array( 'text' ) ) as $attrItem ) |
|
145 | + foreach ($this->getAttributes(array_keys($variantAttributes), array('text')) as $attrItem) |
|
146 | 146 | { |
147 | 147 | $orderAttributeItem = $orderProductAttrManager->createItem(); |
148 | - $orderAttributeItem->copyFrom( $attrItem ); |
|
149 | - $orderAttributeItem->setType( 'variant' ); |
|
148 | + $orderAttributeItem->copyFrom($attrItem); |
|
149 | + $orderAttributeItem->setType('variant'); |
|
150 | 150 | |
151 | 151 | $attr[] = $orderAttributeItem; |
152 | 152 | } |
153 | 153 | } |
154 | - else if( $requireVariant != false ) // count == 0 |
|
154 | + else if ($requireVariant != false) // count == 0 |
|
155 | 155 | { |
156 | - $msg = sprintf( 'No article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
|
157 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
156 | + $msg = sprintf('No article found for selected attributes and product ID "%1$s"', $productItem->getId()); |
|
157 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | return $attr; |
@@ -121,10 +121,11 @@ discard block |
||
121 | 121 | { |
122 | 122 | $msg = sprintf( 'No unique article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
123 | 123 | throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
124 | - } |
|
125 | - else if( ( $result = reset( $productItems ) ) !== false ) // count == 1 |
|
124 | + } else if( ( $result = reset( $productItems ) ) !== false ) { |
|
125 | + // count == 1 |
|
126 | 126 | { |
127 | 127 | $productItem = $result; |
128 | + } |
|
128 | 129 | $orderBaseProductItem->setProductCode( $productItem->getCode() ); |
129 | 130 | |
130 | 131 | $subprices = $productItem->getRefItems( 'price', 'default', 'default' ); |
@@ -150,10 +151,11 @@ discard block |
||
150 | 151 | |
151 | 152 | $attr[] = $orderAttributeItem; |
152 | 153 | } |
153 | - } |
|
154 | - else if( $requireVariant != false ) // count == 0 |
|
154 | + } else if( $requireVariant != false ) { |
|
155 | + // count == 0 |
|
155 | 156 | { |
156 | 157 | $msg = sprintf( 'No article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
158 | + } |
|
157 | 159 | throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
158 | 160 | } |
159 | 161 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param string $type Basket type |
51 | 51 | * @return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object |
52 | 52 | */ |
53 | - public function setType( $type ); |
|
53 | + public function setType($type); |
|
54 | 54 | |
55 | 55 | |
56 | 56 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @param boolean $default True to add default criteria (user logged in), false if not |
70 | 70 | * @return \Aimeos\MShop\Order\Item\Base\Iface Order base object including the given parts |
71 | 71 | */ |
72 | - public function load( $id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true ); |
|
72 | + public function load($id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true); |
|
73 | 73 | |
74 | 74 | |
75 | 75 | /** |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
89 | 89 | * @return void |
90 | 90 | */ |
91 | - public function addProduct( $prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
92 | - array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [] ); |
|
91 | + public function addProduct($prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
92 | + array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = []); |
|
93 | 93 | |
94 | 94 | |
95 | 95 | /** |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @param integer $position Position number (key) of the order product item |
99 | 99 | * @return void |
100 | 100 | */ |
101 | - public function deleteProduct( $position ); |
|
101 | + public function deleteProduct($position); |
|
102 | 102 | |
103 | 103 | |
104 | 104 | /** |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param array $configAttributeCodes Codes of the product config attributes that should be REMOVED |
110 | 110 | * @return void |
111 | 111 | */ |
112 | - public function editProduct( $position, $quantity, array $configAttributeCodes = [] ); |
|
112 | + public function editProduct($position, $quantity, array $configAttributeCodes = []); |
|
113 | 113 | |
114 | 114 | |
115 | 115 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
120 | 120 | * @return void |
121 | 121 | */ |
122 | - public function addCoupon( $code ); |
|
122 | + public function addCoupon($code); |
|
123 | 123 | |
124 | 124 | |
125 | 125 | /** |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
130 | 130 | * @return void |
131 | 131 | */ |
132 | - public function deleteCoupon( $code ); |
|
132 | + public function deleteCoupon($code); |
|
133 | 133 | |
134 | 134 | |
135 | 135 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * if one of the keys is invalid when using an array with key/value pairs |
142 | 142 | * @return void |
143 | 143 | */ |
144 | - public function setAddress( $type, $value ); |
|
144 | + public function setAddress($type, $value); |
|
145 | 145 | |
146 | 146 | |
147 | 147 | /** |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * entered by the customer when choosing one of the delivery or payment options |
154 | 154 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
155 | 155 | */ |
156 | - public function addService( $type, $id, array $attributes = [] ); |
|
156 | + public function addService($type, $id, array $attributes = []); |
|
157 | 157 | |
158 | 158 | |
159 | 159 | /** |
@@ -161,5 +161,5 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @param string $type Service type code like 'payment' or 'delivery' |
163 | 163 | */ |
164 | - public function deleteService( $type ); |
|
164 | + public function deleteService($type); |
|
165 | 165 | } |
@@ -31,50 +31,50 @@ discard block |
||
31 | 31 | * @param integer $quantity New product quantity |
32 | 32 | * @return \Aimeos\MShop\Price\Item\Iface Price item with calculated price |
33 | 33 | */ |
34 | - protected function calcPrice( \Aimeos\MShop\Order\Item\Base\Product\Iface $product, array $prices, $quantity ) |
|
34 | + protected function calcPrice(\Aimeos\MShop\Order\Item\Base\Product\Iface $product, array $prices, $quantity) |
|
35 | 35 | { |
36 | 36 | $context = $this->getContext(); |
37 | 37 | |
38 | - if( empty( $prices ) ) |
|
38 | + if (empty($prices)) |
|
39 | 39 | { |
40 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
41 | - $prices = $manager->getItem( $product->getProductId(), array( 'price' ) )->getRefItems( 'price', 'default' ); |
|
40 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
41 | + $prices = $manager->getItem($product->getProductId(), array('price'))->getRefItems('price', 'default'); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
46 | - $price = $priceManager->getLowestPrice( $prices, $quantity ); |
|
45 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
46 | + $price = $priceManager->getLowestPrice($prices, $quantity); |
|
47 | 47 | |
48 | 48 | // customers can pay what they would like to pay |
49 | - if( ( $attr = $product->getAttributeItem( 'price', 'custom' ) ) !== null ) |
|
49 | + if (($attr = $product->getAttributeItem('price', 'custom')) !== null) |
|
50 | 50 | { |
51 | 51 | $amount = $attr->getValue(); |
52 | 52 | |
53 | - if( preg_match( '/^[0-9]*(\.[0-9]+)?$/', $amount ) !== 1 || ((double) $amount) < 0.01 ) { |
|
54 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Invalid price value "%1$s"', $amount ) ); |
|
53 | + if (preg_match('/^[0-9]*(\.[0-9]+)?$/', $amount) !== 1 || ((double) $amount) < 0.01) { |
|
54 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Invalid price value "%1$s"', $amount)); |
|
55 | 55 | } |
56 | 56 | |
57 | - $price->setValue( $amount ); |
|
57 | + $price->setValue($amount); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | $orderAttributes = $product->getAttributes(); |
61 | - $attrItems = $this->getAttributeItems( $orderAttributes ); |
|
61 | + $attrItems = $this->getAttributeItems($orderAttributes); |
|
62 | 62 | |
63 | 63 | // add prices of (optional) attributes |
64 | - foreach( $orderAttributes as $orderAttrItem ) |
|
64 | + foreach ($orderAttributes as $orderAttrItem) |
|
65 | 65 | { |
66 | 66 | $attrId = $orderAttrItem->getAttributeId(); |
67 | 67 | |
68 | - if( isset( $attrItems[$attrId] ) |
|
69 | - && ( $prices = $attrItems[$attrId]->getRefItems( 'price', 'default' ) ) !== [] |
|
68 | + if (isset($attrItems[$attrId]) |
|
69 | + && ($prices = $attrItems[$attrId]->getRefItems('price', 'default')) !== [] |
|
70 | 70 | ) { |
71 | - $attrPrice = $priceManager->getLowestPrice( $prices, $orderAttrItem->getQuantity() ); |
|
72 | - $price->addItem( $attrPrice, $orderAttrItem->getQuantity() ); |
|
71 | + $attrPrice = $priceManager->getLowestPrice($prices, $orderAttrItem->getQuantity()); |
|
72 | + $price->addItem($attrPrice, $orderAttrItem->getQuantity()); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | 76 | // remove product rebate of original price in favor to rebates granted for the order |
77 | - $price->setRebate( '0.00' ); |
|
77 | + $price->setRebate('0.00'); |
|
78 | 78 | |
79 | 79 | return $price; |
80 | 80 | } |
@@ -88,42 +88,42 @@ discard block |
||
88 | 88 | * @param array $refMap Associative list of list type codes as keys and lists of reference IDs as values |
89 | 89 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated |
90 | 90 | */ |
91 | - protected function checkListRef( $prodId, $domain, array $refMap ) |
|
91 | + protected function checkListRef($prodId, $domain, array $refMap) |
|
92 | 92 | { |
93 | - if( empty( $refMap ) ) { |
|
93 | + if (empty($refMap)) { |
|
94 | 94 | return; |
95 | 95 | } |
96 | 96 | |
97 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
98 | - $search = $productManager->createSearch( true ); |
|
97 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
98 | + $search = $productManager->createSearch(true); |
|
99 | 99 | |
100 | 100 | $expr = array( |
101 | - $search->compare( '==', 'product.id', $prodId ), |
|
101 | + $search->compare('==', 'product.id', $prodId), |
|
102 | 102 | $search->getConditions(), |
103 | 103 | ); |
104 | 104 | |
105 | - foreach( $refMap as $listType => $refIds ) |
|
105 | + foreach ($refMap as $listType => $refIds) |
|
106 | 106 | { |
107 | - if( empty( $refIds ) ) { |
|
107 | + if (empty($refIds)) { |
|
108 | 108 | continue; |
109 | 109 | } |
110 | 110 | |
111 | - foreach( $refIds as $key => $refId ) { |
|
111 | + foreach ($refIds as $key => $refId) { |
|
112 | 112 | $refIds[$key] = (string) $refId; |
113 | 113 | } |
114 | 114 | |
115 | - $param = array( $domain, $this->getProductListTypeItem( $domain, $listType )->getId(), $refIds ); |
|
116 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
115 | + $param = array($domain, $this->getProductListTypeItem($domain, $listType)->getId(), $refIds); |
|
116 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
117 | 117 | |
118 | - $expr[] = $search->compare( '==', $cmpfunc, count( $refIds ) ); |
|
118 | + $expr[] = $search->compare('==', $cmpfunc, count($refIds)); |
|
119 | 119 | } |
120 | 120 | |
121 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
121 | + $search->setConditions($search->combine('&&', $expr)); |
|
122 | 122 | |
123 | - if( count( $productManager->searchItems( $search, [] ) ) === 0 ) |
|
123 | + if (count($productManager->searchItems($search, [])) === 0) |
|
124 | 124 | { |
125 | - $msg = sprintf( 'Invalid "%1$s" references for product with ID %2$s', $domain, json_encode( $prodId ) ); |
|
126 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
125 | + $msg = sprintf('Invalid "%1$s" references for product with ID %2$s', $domain, json_encode($prodId)); |
|
126 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
@@ -138,34 +138,34 @@ discard block |
||
138 | 138 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated |
139 | 139 | * @deprecated Use checkListRef() instead |
140 | 140 | */ |
141 | - protected function checkReferences( $prodId, $domain, $listTypeId, array $refIds ) |
|
141 | + protected function checkReferences($prodId, $domain, $listTypeId, array $refIds) |
|
142 | 142 | { |
143 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
144 | - $search = $productManager->createSearch( true ); |
|
143 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
144 | + $search = $productManager->createSearch(true); |
|
145 | 145 | |
146 | 146 | $expr = array( |
147 | - $search->compare( '==', 'product.id', $prodId ), |
|
147 | + $search->compare('==', 'product.id', $prodId), |
|
148 | 148 | $search->getConditions(), |
149 | 149 | ); |
150 | 150 | |
151 | - if( count( $refIds ) > 0 ) |
|
151 | + if (count($refIds) > 0) |
|
152 | 152 | { |
153 | - foreach( $refIds as $key => $refId ) { |
|
153 | + foreach ($refIds as $key => $refId) { |
|
154 | 154 | $refIds[$key] = (string) $refId; |
155 | 155 | } |
156 | 156 | |
157 | - $param = array( $domain, $listTypeId, $refIds ); |
|
158 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
157 | + $param = array($domain, $listTypeId, $refIds); |
|
158 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
159 | 159 | |
160 | - $expr[] = $search->compare( '==', $cmpfunc, count( $refIds ) ); |
|
160 | + $expr[] = $search->compare('==', $cmpfunc, count($refIds)); |
|
161 | 161 | } |
162 | 162 | |
163 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
163 | + $search->setConditions($search->combine('&&', $expr)); |
|
164 | 164 | |
165 | - if( count( $productManager->searchItems( $search, [] ) ) === 0 ) |
|
165 | + if (count($productManager->searchItems($search, [])) === 0) |
|
166 | 166 | { |
167 | - $msg = sprintf( 'Invalid "%1$s" references for product with ID %2$s', $domain, json_encode( $prodId ) ); |
|
168 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
167 | + $msg = sprintf('Invalid "%1$s" references for product with ID %2$s', $domain, json_encode($prodId)); |
|
168 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
@@ -175,41 +175,41 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @param string $type Basket type |
177 | 177 | */ |
178 | - protected function checkLocale( $type ) |
|
178 | + protected function checkLocale($type) |
|
179 | 179 | { |
180 | 180 | $errors = []; |
181 | 181 | $context = $this->getContext(); |
182 | 182 | $session = $context->getSession(); |
183 | 183 | $locale = $this->get()->getLocale(); |
184 | 184 | |
185 | - $localeStr = $session->get( 'aimeos/basket/locale' ); |
|
185 | + $localeStr = $session->get('aimeos/basket/locale'); |
|
186 | 186 | $localeKey = $locale->getSite()->getCode() . '|' . $locale->getLanguageId() . '|' . $locale->getCurrencyId(); |
187 | 187 | |
188 | - if( $localeStr !== null && $localeStr !== $localeKey ) |
|
188 | + if ($localeStr !== null && $localeStr !== $localeKey) |
|
189 | 189 | { |
190 | - $locParts = explode( '|', $localeStr ); |
|
191 | - $locSite = ( isset( $locParts[0] ) ? $locParts[0] : '' ); |
|
192 | - $locLanguage = ( isset( $locParts[1] ) ? $locParts[1] : '' ); |
|
193 | - $locCurrency = ( isset( $locParts[2] ) ? $locParts[2] : '' ); |
|
190 | + $locParts = explode('|', $localeStr); |
|
191 | + $locSite = (isset($locParts[0]) ? $locParts[0] : ''); |
|
192 | + $locLanguage = (isset($locParts[1]) ? $locParts[1] : ''); |
|
193 | + $locCurrency = (isset($locParts[2]) ? $locParts[2] : ''); |
|
194 | 194 | |
195 | - $localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' ); |
|
196 | - $locale = $localeManager->bootstrap( $locSite, $locLanguage, $locCurrency, false ); |
|
195 | + $localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale'); |
|
196 | + $locale = $localeManager->bootstrap($locSite, $locLanguage, $locCurrency, false); |
|
197 | 197 | |
198 | 198 | $context = clone $context; |
199 | - $context->setLocale( $locale ); |
|
199 | + $context->setLocale($locale); |
|
200 | 200 | |
201 | - $manager = \Aimeos\MShop\Order\Manager\Factory::createManager( $context )->getSubManager( 'base' ); |
|
202 | - $basket = $manager->getSession( $type ); |
|
201 | + $manager = \Aimeos\MShop\Order\Manager\Factory::createManager($context)->getSubManager('base'); |
|
202 | + $basket = $manager->getSession($type); |
|
203 | 203 | |
204 | - $this->copyAddresses( $basket, $errors, $localeKey ); |
|
205 | - $this->copyServices( $basket, $errors ); |
|
206 | - $this->copyProducts( $basket, $errors, $localeKey ); |
|
207 | - $this->copyCoupons( $basket, $errors, $localeKey ); |
|
204 | + $this->copyAddresses($basket, $errors, $localeKey); |
|
205 | + $this->copyServices($basket, $errors); |
|
206 | + $this->copyProducts($basket, $errors, $localeKey); |
|
207 | + $this->copyCoupons($basket, $errors, $localeKey); |
|
208 | 208 | |
209 | - $manager->setSession( $basket, $type ); |
|
209 | + $manager->setSession($basket, $type); |
|
210 | 210 | } |
211 | 211 | |
212 | - $session->set( 'aimeos/basket/locale', $localeKey ); |
|
212 | + $session->set('aimeos/basket/locale', $localeKey); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
@@ -221,20 +221,20 @@ discard block |
||
221 | 221 | * @param string $localeKey Unique identifier of the site, language and currency |
222 | 222 | * @return array Associative list of errors occured |
223 | 223 | */ |
224 | - protected function copyAddresses( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
224 | + protected function copyAddresses(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
225 | 225 | { |
226 | - foreach( $basket->getAddresses() as $type => $item ) |
|
226 | + foreach ($basket->getAddresses() as $type => $item) |
|
227 | 227 | { |
228 | 228 | try |
229 | 229 | { |
230 | - $this->setAddress( $type, $item->toArray() ); |
|
231 | - $basket->deleteAddress( $type ); |
|
230 | + $this->setAddress($type, $item->toArray()); |
|
231 | + $basket->deleteAddress($type); |
|
232 | 232 | } |
233 | - catch( \Exception $e ) |
|
233 | + catch (\Exception $e) |
|
234 | 234 | { |
235 | 235 | $logger = $this->getContext()->getLogger(); |
236 | 236 | $str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s'; |
237 | - $logger->log( sprintf( $str, $type, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
237 | + $logger->log(sprintf($str, $type, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
238 | 238 | $errors['address'][$type] = $e->getMessage(); |
239 | 239 | } |
240 | 240 | } |
@@ -251,20 +251,20 @@ discard block |
||
251 | 251 | * @param string $localeKey Unique identifier of the site, language and currency |
252 | 252 | * @return array Associative list of errors occured |
253 | 253 | */ |
254 | - protected function copyCoupons( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
254 | + protected function copyCoupons(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
255 | 255 | { |
256 | - foreach( $basket->getCoupons() as $code => $list ) |
|
256 | + foreach ($basket->getCoupons() as $code => $list) |
|
257 | 257 | { |
258 | 258 | try |
259 | 259 | { |
260 | - $this->addCoupon( $code ); |
|
261 | - $basket->deleteCoupon( $code, true ); |
|
260 | + $this->addCoupon($code); |
|
261 | + $basket->deleteCoupon($code, true); |
|
262 | 262 | } |
263 | - catch( \Exception $e ) |
|
263 | + catch (\Exception $e) |
|
264 | 264 | { |
265 | 265 | $logger = $this->getContext()->getLogger(); |
266 | 266 | $str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s'; |
267 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
267 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
268 | 268 | $errors['coupon'][$code] = $e->getMessage(); |
269 | 269 | } |
270 | 270 | } |
@@ -281,11 +281,11 @@ discard block |
||
281 | 281 | * @param string $localeKey Unique identifier of the site, language and currency |
282 | 282 | * @return array Associative list of errors occured |
283 | 283 | */ |
284 | - protected function copyProducts( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
284 | + protected function copyProducts(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
285 | 285 | { |
286 | - foreach( $basket->getProducts() as $pos => $product ) |
|
286 | + foreach ($basket->getProducts() as $pos => $product) |
|
287 | 287 | { |
288 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) { |
|
288 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) { |
|
289 | 289 | continue; |
290 | 290 | } |
291 | 291 | |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | { |
294 | 294 | $attrIds = []; |
295 | 295 | |
296 | - foreach( $product->getAttributes() as $attrItem ) { |
|
296 | + foreach ($product->getAttributes() as $attrItem) { |
|
297 | 297 | $attrIds[$attrItem->getType()][] = $attrItem->getAttributeId(); |
298 | 298 | } |
299 | 299 | |
@@ -301,22 +301,22 @@ discard block |
||
301 | 301 | $product->getProductId(), |
302 | 302 | $product->getQuantity(), |
303 | 303 | $product->getStockType(), |
304 | - $this->getValue( $attrIds, 'variant', [] ), |
|
305 | - $this->getValue( $attrIds, 'config', [] ), |
|
306 | - $this->getValue( $attrIds, 'hidden', [] ), |
|
307 | - $this->getValue( $attrIds, 'custom', [] ) |
|
304 | + $this->getValue($attrIds, 'variant', []), |
|
305 | + $this->getValue($attrIds, 'config', []), |
|
306 | + $this->getValue($attrIds, 'hidden', []), |
|
307 | + $this->getValue($attrIds, 'custom', []) |
|
308 | 308 | ); |
309 | 309 | |
310 | - $basket->deleteProduct( $pos ); |
|
310 | + $basket->deleteProduct($pos); |
|
311 | 311 | } |
312 | - catch( \Exception $e ) |
|
312 | + catch (\Exception $e) |
|
313 | 313 | { |
314 | 314 | $code = $product->getProductCode(); |
315 | 315 | $logger = $this->getContext()->getLogger(); |
316 | 316 | $errors['product'][$pos] = $e->getMessage(); |
317 | 317 | |
318 | 318 | $str = 'Error migrating product with code "%1$s" in basket to locale "%2$s": %3$s'; |
319 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
319 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
@@ -331,24 +331,24 @@ discard block |
||
331 | 331 | * @param array $errors Associative list of previous errors |
332 | 332 | * @return array Associative list of errors occured |
333 | 333 | */ |
334 | - protected function copyServices( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors ) |
|
334 | + protected function copyServices(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors) |
|
335 | 335 | { |
336 | - foreach( $basket->getServices() as $type => $list ) |
|
336 | + foreach ($basket->getServices() as $type => $list) |
|
337 | 337 | { |
338 | - foreach( $list as $item ) |
|
338 | + foreach ($list as $item) |
|
339 | 339 | { |
340 | 340 | try |
341 | 341 | { |
342 | 342 | $attributes = []; |
343 | 343 | |
344 | - foreach( $item->getAttributes() as $attrItem ) { |
|
344 | + foreach ($item->getAttributes() as $attrItem) { |
|
345 | 345 | $attributes[$attrItem->getCode()] = $attrItem->getValue(); |
346 | 346 | } |
347 | 347 | |
348 | - $this->addService( $type, $item->getServiceId(), $attributes ); |
|
349 | - $basket->deleteService( $type ); |
|
348 | + $this->addService($type, $item->getServiceId(), $attributes); |
|
349 | + $basket->deleteService($type); |
|
350 | 350 | } |
351 | - catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically |
|
351 | + catch (\Exception $e) {; } // Don't notify the user as appropriate services can be added automatically |
|
352 | 352 | } |
353 | 353 | } |
354 | 354 | |
@@ -368,36 +368,36 @@ discard block |
||
368 | 368 | * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface |
369 | 369 | * @deprecated Use getOrderProductAttributes(), checkReferences() and calcPrice() instead |
370 | 370 | */ |
371 | - protected function createOrderProductAttributes( \Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
372 | - array $attributeIds, $type, array $attributeValues = [] ) |
|
371 | + protected function createOrderProductAttributes(\Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
372 | + array $attributeIds, $type, array $attributeValues = []) |
|
373 | 373 | { |
374 | - if( empty( $attributeIds ) ) { |
|
374 | + if (empty($attributeIds)) { |
|
375 | 375 | return []; |
376 | 376 | } |
377 | 377 | |
378 | - $attrTypeId = $this->getProductListTypeItem( 'attribute', $type )->getId(); |
|
379 | - $this->checkReferences( $prodid, 'attribute', $attrTypeId, $attributeIds ); |
|
378 | + $attrTypeId = $this->getProductListTypeItem('attribute', $type)->getId(); |
|
379 | + $this->checkReferences($prodid, 'attribute', $attrTypeId, $attributeIds); |
|
380 | 380 | |
381 | 381 | $list = []; |
382 | 382 | $context = $this->getContext(); |
383 | 383 | |
384 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
385 | - $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product/attribute' ); |
|
384 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
385 | + $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product/attribute'); |
|
386 | 386 | |
387 | - foreach( $this->getAttributes( $attributeIds ) as $id => $attrItem ) |
|
387 | + foreach ($this->getAttributes($attributeIds) as $id => $attrItem) |
|
388 | 388 | { |
389 | - $prices = $attrItem->getRefItems( 'price', 'default', 'default' ); |
|
389 | + $prices = $attrItem->getRefItems('price', 'default', 'default'); |
|
390 | 390 | |
391 | - if( !empty( $prices ) ) { |
|
392 | - $price->addItem( $priceManager->getLowestPrice( $prices, $quantity ) ); |
|
391 | + if (!empty($prices)) { |
|
392 | + $price->addItem($priceManager->getLowestPrice($prices, $quantity)); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | $item = $orderProductAttributeManager->createItem(); |
396 | - $item->copyFrom( $attrItem ); |
|
397 | - $item->setType( $type ); |
|
396 | + $item->copyFrom($attrItem); |
|
397 | + $item->setType($type); |
|
398 | 398 | |
399 | - if( isset( $attributeValues[$id] ) ) { |
|
400 | - $item->setValue( $attributeValues[$id] ); |
|
399 | + if (isset($attributeValues[$id])) { |
|
400 | + $item->setValue($attributeValues[$id]); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | $list[] = $item; |
@@ -415,31 +415,31 @@ discard block |
||
415 | 415 | * @return array List of items implementing \Aimeos\MShop\Attribute\Item\Iface |
416 | 416 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the actual attribute number doesn't match the expected one |
417 | 417 | */ |
418 | - protected function getAttributes( array $attributeIds, array $domains = array( 'price', 'text' ) ) |
|
418 | + protected function getAttributes(array $attributeIds, array $domains = array('price', 'text')) |
|
419 | 419 | { |
420 | - if( empty( $attributeIds ) ) { |
|
420 | + if (empty($attributeIds)) { |
|
421 | 421 | return []; |
422 | 422 | } |
423 | 423 | |
424 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
424 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
425 | 425 | |
426 | - $search = $attributeManager->createSearch( true ); |
|
426 | + $search = $attributeManager->createSearch(true); |
|
427 | 427 | $expr = array( |
428 | - $search->compare( '==', 'attribute.id', $attributeIds ), |
|
428 | + $search->compare('==', 'attribute.id', $attributeIds), |
|
429 | 429 | $search->getConditions(), |
430 | 430 | ); |
431 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
432 | - $search->setSlice( 0, 0x7fffffff ); |
|
431 | + $search->setConditions($search->combine('&&', $expr)); |
|
432 | + $search->setSlice(0, 0x7fffffff); |
|
433 | 433 | |
434 | - $attrItems = $attributeManager->searchItems( $search, $domains ); |
|
434 | + $attrItems = $attributeManager->searchItems($search, $domains); |
|
435 | 435 | |
436 | - if( count( $attrItems ) !== count( $attributeIds ) ) |
|
436 | + if (count($attrItems) !== count($attributeIds)) |
|
437 | 437 | { |
438 | - $expected = implode( ',', $attributeIds ); |
|
439 | - $actual = implode( ',', array_keys( $attrItems ) ); |
|
440 | - $msg = sprintf( 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected ); |
|
438 | + $expected = implode(',', $attributeIds); |
|
439 | + $actual = implode(',', array_keys($attrItems)); |
|
440 | + $msg = sprintf('Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected); |
|
441 | 441 | |
442 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
442 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | return $attrItems; |
@@ -452,31 +452,31 @@ discard block |
||
452 | 452 | * @param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Item[] $orderAttributes List of order product attribute items |
453 | 453 | * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as key and attribute items as values |
454 | 454 | */ |
455 | - protected function getAttributeItems( array $orderAttributes ) |
|
455 | + protected function getAttributeItems(array $orderAttributes) |
|
456 | 456 | { |
457 | - if( empty( $orderAttributes ) ) { |
|
457 | + if (empty($orderAttributes)) { |
|
458 | 458 | return []; |
459 | 459 | } |
460 | 460 | |
461 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
462 | - $search = $attributeManager->createSearch( true ); |
|
461 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
462 | + $search = $attributeManager->createSearch(true); |
|
463 | 463 | $expr = []; |
464 | 464 | |
465 | - foreach( $orderAttributes as $item ) |
|
465 | + foreach ($orderAttributes as $item) |
|
466 | 466 | { |
467 | 467 | $tmp = array( |
468 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
469 | - $search->compare( '==', 'attribute.code', $item->getValue() ), |
|
470 | - $search->compare( '==', 'attribute.type.domain', 'product' ), |
|
471 | - $search->compare( '==', 'attribute.type.code', $item->getCode() ), |
|
472 | - $search->compare( '>', 'attribute.type.status', 0 ), |
|
468 | + $search->compare('==', 'attribute.domain', 'product'), |
|
469 | + $search->compare('==', 'attribute.code', $item->getValue()), |
|
470 | + $search->compare('==', 'attribute.type.domain', 'product'), |
|
471 | + $search->compare('==', 'attribute.type.code', $item->getCode()), |
|
472 | + $search->compare('>', 'attribute.type.status', 0), |
|
473 | 473 | $search->getConditions(), |
474 | 474 | ); |
475 | - $expr[] = $search->combine( '&&', $tmp ); |
|
475 | + $expr[] = $search->combine('&&', $tmp); |
|
476 | 476 | } |
477 | 477 | |
478 | - $search->setConditions( $search->combine( '||', $expr ) ); |
|
479 | - return $attributeManager->searchItems( $search, array( 'price' ) ); |
|
478 | + $search->setConditions($search->combine('||', $expr)); |
|
479 | + return $attributeManager->searchItems($search, array('price')); |
|
480 | 480 | } |
481 | 481 | |
482 | 482 | |
@@ -491,23 +491,23 @@ discard block |
||
491 | 491 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
492 | 492 | * @deprecated Use getItem() or findItem() instead |
493 | 493 | */ |
494 | - protected function getDomainItem( $domain, $key, $value, array $ref ) |
|
494 | + protected function getDomainItem($domain, $key, $value, array $ref) |
|
495 | 495 | { |
496 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $domain ); |
|
496 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $domain); |
|
497 | 497 | |
498 | - $search = $manager->createSearch( true ); |
|
498 | + $search = $manager->createSearch(true); |
|
499 | 499 | $expr = array( |
500 | - $search->compare( '==', $key, $value ), |
|
500 | + $search->compare('==', $key, $value), |
|
501 | 501 | $search->getConditions(), |
502 | 502 | ); |
503 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
503 | + $search->setConditions($search->combine('&&', $expr)); |
|
504 | 504 | |
505 | - $result = $manager->searchItems( $search, $ref ); |
|
505 | + $result = $manager->searchItems($search, $ref); |
|
506 | 506 | |
507 | - if( ( $item = reset( $result ) ) === false ) |
|
507 | + if (($item = reset($result)) === false) |
|
508 | 508 | { |
509 | - $msg = sprintf( 'No item for "%1$s" (%2$s) found', $value, $key ); |
|
510 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
509 | + $msg = sprintf('No item for "%1$s" (%2$s) found', $value, $key); |
|
510 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | return $item; |
@@ -523,24 +523,24 @@ discard block |
||
523 | 523 | * @param array $quantities Associative list of attribute IDs as keys and their quantities as values |
524 | 524 | * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface |
525 | 525 | */ |
526 | - protected function getOrderProductAttributes( $type, array $ids, array $values = [], array $quantities = [] ) |
|
526 | + protected function getOrderProductAttributes($type, array $ids, array $values = [], array $quantities = []) |
|
527 | 527 | { |
528 | - if( empty( $ids ) ) { |
|
528 | + if (empty($ids)) { |
|
529 | 529 | return []; |
530 | 530 | } |
531 | 531 | |
532 | 532 | $list = []; |
533 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product/attribute' ); |
|
533 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product/attribute'); |
|
534 | 534 | |
535 | - foreach( $this->getAttributes( $ids ) as $id => $attrItem ) |
|
535 | + foreach ($this->getAttributes($ids) as $id => $attrItem) |
|
536 | 536 | { |
537 | 537 | $item = $manager->createItem(); |
538 | - $item->copyFrom( $attrItem ); |
|
539 | - $item->setType( $type ); |
|
540 | - $item->setQuantity( isset( $quantities[$id] ) ? $quantities[$id] : 1 ); |
|
538 | + $item->copyFrom($attrItem); |
|
539 | + $item->setType($type); |
|
540 | + $item->setQuantity(isset($quantities[$id]) ? $quantities[$id] : 1); |
|
541 | 541 | |
542 | - if( isset( $values[$id] ) ) { |
|
543 | - $item->setValue( $values[$id] ); |
|
542 | + if (isset($values[$id])) { |
|
543 | + $item->setValue($values[$id]); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | $list[] = $item; |
@@ -557,21 +557,21 @@ discard block |
||
557 | 557 | * @param string $code Code of the list type |
558 | 558 | * @return \Aimeos\MShop\Common\Item\Type\Iface List type item |
559 | 559 | */ |
560 | - protected function getProductListTypeItem( $domain, $code ) |
|
560 | + protected function getProductListTypeItem($domain, $code) |
|
561 | 561 | { |
562 | - if( empty( $this->listTypeItems ) ) |
|
562 | + if (empty($this->listTypeItems)) |
|
563 | 563 | { |
564 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists/type' ); |
|
564 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists/type'); |
|
565 | 565 | |
566 | - foreach( $manager->searchItems( $manager->createSearch( true ) ) as $item ) { |
|
567 | - $this->listTypeItems[ $item->getDomain() ][ $item->getCode() ] = $item; |
|
566 | + foreach ($manager->searchItems($manager->createSearch(true)) as $item) { |
|
567 | + $this->listTypeItems[$item->getDomain()][$item->getCode()] = $item; |
|
568 | 568 | } |
569 | 569 | } |
570 | 570 | |
571 | - if( !isset( $this->listTypeItems[$domain][$code] ) ) |
|
571 | + if (!isset($this->listTypeItems[$domain][$code])) |
|
572 | 572 | { |
573 | - $msg = sprintf( 'List type for domain "%1$s" and code "%2$s" not found', $domain, $code ); |
|
574 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
573 | + $msg = sprintf('List type for domain "%1$s" and code "%2$s" not found', $domain, $code); |
|
574 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | return $this->listTypeItems[$domain][$code]; |
@@ -586,43 +586,43 @@ discard block |
||
586 | 586 | * @param array $domains Names of the domain items that should be fetched too |
587 | 587 | * @return array List of products matching the given attributes |
588 | 588 | */ |
589 | - protected function getProductVariants( \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
590 | - array $domains = array( 'attribute', 'media', 'price', 'text' ) ) |
|
589 | + protected function getProductVariants(\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
590 | + array $domains = array('attribute', 'media', 'price', 'text')) |
|
591 | 591 | { |
592 | 592 | $subProductIds = []; |
593 | - foreach( $productItem->getRefItems( 'product', 'default', 'default' ) as $item ) { |
|
593 | + foreach ($productItem->getRefItems('product', 'default', 'default') as $item) { |
|
594 | 594 | $subProductIds[] = $item->getId(); |
595 | 595 | } |
596 | 596 | |
597 | - if( count( $subProductIds ) === 0 ) { |
|
597 | + if (count($subProductIds) === 0) { |
|
598 | 598 | return []; |
599 | 599 | } |
600 | 600 | |
601 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
602 | - $search = $productManager->createSearch( true ); |
|
601 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
602 | + $search = $productManager->createSearch(true); |
|
603 | 603 | |
604 | 604 | $expr = array( |
605 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
605 | + $search->compare('==', 'product.id', $subProductIds), |
|
606 | 606 | $search->getConditions(), |
607 | 607 | ); |
608 | 608 | |
609 | - if( count( $variantAttributeIds ) > 0 ) |
|
609 | + if (count($variantAttributeIds) > 0) |
|
610 | 610 | { |
611 | - foreach( $variantAttributeIds as $key => $id ) { |
|
611 | + foreach ($variantAttributeIds as $key => $id) { |
|
612 | 612 | $variantAttributeIds[$key] = (string) $id; |
613 | 613 | } |
614 | 614 | |
615 | - $listTypeItem = $this->getProductListTypeItem( 'attribute', 'variant' ); |
|
615 | + $listTypeItem = $this->getProductListTypeItem('attribute', 'variant'); |
|
616 | 616 | |
617 | - $param = array( 'attribute', $listTypeItem->getId(), $variantAttributeIds ); |
|
618 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
617 | + $param = array('attribute', $listTypeItem->getId(), $variantAttributeIds); |
|
618 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
619 | 619 | |
620 | - $expr[] = $search->compare( '==', $cmpfunc, count( $variantAttributeIds ) ); |
|
620 | + $expr[] = $search->compare('==', $cmpfunc, count($variantAttributeIds)); |
|
621 | 621 | } |
622 | 622 | |
623 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
623 | + $search->setConditions($search->combine('&&', $expr)); |
|
624 | 624 | |
625 | - return $productManager->searchItems( $search, $domains ); |
|
625 | + return $productManager->searchItems($search, $domains); |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | |
@@ -634,9 +634,9 @@ discard block |
||
634 | 634 | * @param mixed $default Default value if no value is available for the given name |
635 | 635 | * @return mixed Value from the array or default value |
636 | 636 | */ |
637 | - protected function getValue( array $values, $name, $default = null ) |
|
637 | + protected function getValue(array $values, $name, $default = null) |
|
638 | 638 | { |
639 | - if( isset( $values[$name] ) ) { |
|
639 | + if (isset($values[$name])) { |
|
640 | 640 | return $values[$name]; |
641 | 641 | } |
642 | 642 |