@@ -12,35 +12,35 @@ |
||
12 | 12 | protected function setUp() |
13 | 13 | { |
14 | 14 | $this->context = \TestHelperFrontend::getContext(); |
15 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
16 | - $this->object = new \Aimeos\Controller\Frontend\Basket\Decorator\Category( $object, $this->context ); |
|
15 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
16 | + $this->object = new \Aimeos\Controller\Frontend\Basket\Decorator\Category($object, $this->context); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | |
20 | 20 | protected function tearDown() |
21 | 21 | { |
22 | 22 | $this->object->clear(); |
23 | - $this->context->getSession()->set( 'aimeos', array() ); |
|
23 | + $this->context->getSession()->set('aimeos', array()); |
|
24 | 24 | |
25 | - unset( $this->object ); |
|
25 | + unset($this->object); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
29 | 29 | public function testAddProductWithCategory() |
30 | 30 | { |
31 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' ); |
|
32 | - $item = $manager->findItem( 'CNE' ); |
|
31 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'product'); |
|
32 | + $item = $manager->findItem('CNE'); |
|
33 | 33 | |
34 | - $this->object->addProduct( $item->getId(), 5 ); |
|
34 | + $this->object->addProduct($item->getId(), 5); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
38 | 38 | public function testAddProductNoCategory() |
39 | 39 | { |
40 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' ); |
|
41 | - $item = $manager->findItem( 'ABCD' ); |
|
40 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'product'); |
|
41 | + $item = $manager->findItem('ABCD'); |
|
42 | 42 | |
43 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Basket\Exception' ); |
|
44 | - $this->object->addProduct( $item->getId(), 5 ); |
|
43 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Basket\Exception'); |
|
44 | + $this->object->addProduct($item->getId(), 5); |
|
45 | 45 | } |
46 | 46 | } |
@@ -160,8 +160,7 @@ discard block |
||
160 | 160 | { |
161 | 161 | $this->setAddress( $type, $item->toArray() ); |
162 | 162 | $basket->deleteAddress( $type ); |
163 | - } |
|
164 | - catch( \Exception $e ) |
|
163 | + } catch( \Exception $e ) |
|
165 | 164 | { |
166 | 165 | $logger = $this->getContext()->getLogger(); |
167 | 166 | $str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s'; |
@@ -190,8 +189,7 @@ discard block |
||
190 | 189 | { |
191 | 190 | $this->addCoupon( $code ); |
192 | 191 | $basket->deleteCoupon( $code, true ); |
193 | - } |
|
194 | - catch( \Exception $e ) |
|
192 | + } catch( \Exception $e ) |
|
195 | 193 | { |
196 | 194 | $logger = $this->getContext()->getLogger(); |
197 | 195 | $str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s'; |
@@ -240,8 +238,7 @@ discard block |
||
240 | 238 | ); |
241 | 239 | |
242 | 240 | $basket->deleteProduct( $pos ); |
243 | - } |
|
244 | - catch( \Exception $e ) |
|
241 | + } catch( \Exception $e ) |
|
245 | 242 | { |
246 | 243 | $code = $product->getProductCode(); |
247 | 244 | $logger = $this->getContext()->getLogger(); |
@@ -276,8 +273,7 @@ discard block |
||
276 | 273 | |
277 | 274 | $this->setService( $type, $item->getServiceId(), $attributes ); |
278 | 275 | $basket->deleteService( $type ); |
279 | - } |
|
280 | - catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically |
|
276 | + } catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically |
|
281 | 277 | } |
282 | 278 | |
283 | 279 | return $errors; |
@@ -31,32 +31,32 @@ 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 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
45 | - $price = $priceManager->getLowestPrice( $prices, $quantity ); |
|
44 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
45 | + $price = $priceManager->getLowestPrice($prices, $quantity); |
|
46 | 46 | |
47 | - foreach( $this->getAttributeItems( $product->getAttributes() ) as $attrItem ) |
|
47 | + foreach ($this->getAttributeItems($product->getAttributes()) as $attrItem) |
|
48 | 48 | { |
49 | - $prices = $attrItem->getRefItems( 'price', 'default' ); |
|
49 | + $prices = $attrItem->getRefItems('price', 'default'); |
|
50 | 50 | |
51 | - if( count( $prices ) > 0 ) |
|
51 | + if (count($prices) > 0) |
|
52 | 52 | { |
53 | - $attrPrice = $priceManager->getLowestPrice( $prices, $quantity ); |
|
54 | - $price->addItem( $attrPrice ); |
|
53 | + $attrPrice = $priceManager->getLowestPrice($prices, $quantity); |
|
54 | + $price->addItem($attrPrice); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | 58 | // remove product rebate of original price in favor to rebates granted for the order |
59 | - $price->setRebate( '0.00' ); |
|
59 | + $price->setRebate('0.00'); |
|
60 | 60 | |
61 | 61 | return $price; |
62 | 62 | } |
@@ -71,34 +71,34 @@ discard block |
||
71 | 71 | * @param array $refIds List of IDs that must be associated to the product |
72 | 72 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated |
73 | 73 | */ |
74 | - protected function checkReferences( $prodId, $domain, $listTypeId, array $refIds ) |
|
74 | + protected function checkReferences($prodId, $domain, $listTypeId, array $refIds) |
|
75 | 75 | { |
76 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
77 | - $search = $productManager->createSearch( true ); |
|
76 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
77 | + $search = $productManager->createSearch(true); |
|
78 | 78 | |
79 | 79 | $expr = array( |
80 | - $search->compare( '==', 'product.id', $prodId ), |
|
80 | + $search->compare('==', 'product.id', $prodId), |
|
81 | 81 | $search->getConditions(), |
82 | 82 | ); |
83 | 83 | |
84 | - if( count( $refIds ) > 0 ) |
|
84 | + if (count($refIds) > 0) |
|
85 | 85 | { |
86 | - foreach( $refIds as $key => $refId ) { |
|
86 | + foreach ($refIds as $key => $refId) { |
|
87 | 87 | $refIds[$key] = (string) $refId; |
88 | 88 | } |
89 | 89 | |
90 | - $param = array( $domain, $listTypeId, $refIds ); |
|
91 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
90 | + $param = array($domain, $listTypeId, $refIds); |
|
91 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
92 | 92 | |
93 | - $expr[] = $search->compare( '==', $cmpfunc, count( $refIds ) ); |
|
93 | + $expr[] = $search->compare('==', $cmpfunc, count($refIds)); |
|
94 | 94 | } |
95 | 95 | |
96 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
96 | + $search->setConditions($search->combine('&&', $expr)); |
|
97 | 97 | |
98 | - if( count( $productManager->searchItems( $search, array() ) ) === 0 ) |
|
98 | + if (count($productManager->searchItems($search, array())) === 0) |
|
99 | 99 | { |
100 | - $msg = sprintf( 'Invalid "%1$s" references for product with ID "%2$s"', $domain, $prodId ); |
|
101 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
100 | + $msg = sprintf('Invalid "%1$s" references for product with ID "%2$s"', $domain, $prodId); |
|
101 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
@@ -113,34 +113,34 @@ discard block |
||
113 | 113 | $session = $context->getSession(); |
114 | 114 | $locale = $this->get()->getLocale(); |
115 | 115 | |
116 | - $localeStr = $session->get( 'aimeos/basket/locale' ); |
|
116 | + $localeStr = $session->get('aimeos/basket/locale'); |
|
117 | 117 | $localeKey = $locale->getSite()->getCode() . '|' . $locale->getLanguageId() . '|' . $locale->getCurrencyId(); |
118 | 118 | |
119 | - if( $localeStr !== null && $localeStr !== $localeKey ) |
|
119 | + if ($localeStr !== null && $localeStr !== $localeKey) |
|
120 | 120 | { |
121 | - $locParts = explode( '|', $localeStr ); |
|
122 | - $locSite = ( isset( $locParts[0] ) ? $locParts[0] : '' ); |
|
123 | - $locLanguage = ( isset( $locParts[1] ) ? $locParts[1] : '' ); |
|
124 | - $locCurrency = ( isset( $locParts[2] ) ? $locParts[2] : '' ); |
|
121 | + $locParts = explode('|', $localeStr); |
|
122 | + $locSite = (isset($locParts[0]) ? $locParts[0] : ''); |
|
123 | + $locLanguage = (isset($locParts[1]) ? $locParts[1] : ''); |
|
124 | + $locCurrency = (isset($locParts[2]) ? $locParts[2] : ''); |
|
125 | 125 | |
126 | - $localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' ); |
|
127 | - $locale = $localeManager->bootstrap( $locSite, $locLanguage, $locCurrency, false ); |
|
126 | + $localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale'); |
|
127 | + $locale = $localeManager->bootstrap($locSite, $locLanguage, $locCurrency, false); |
|
128 | 128 | |
129 | 129 | $context = clone $context; |
130 | - $context->setLocale( $locale ); |
|
130 | + $context->setLocale($locale); |
|
131 | 131 | |
132 | - $manager = \Aimeos\MShop\Order\Manager\Factory::createManager( $context )->getSubManager( 'base' ); |
|
132 | + $manager = \Aimeos\MShop\Order\Manager\Factory::createManager($context)->getSubManager('base'); |
|
133 | 133 | $basket = $manager->getSession(); |
134 | 134 | |
135 | - $this->copyAddresses( $basket, $errors, $localeKey ); |
|
136 | - $this->copyServices( $basket, $errors ); |
|
137 | - $this->copyProducts( $basket, $errors, $localeKey ); |
|
138 | - $this->copyCoupons( $basket, $errors, $localeKey ); |
|
135 | + $this->copyAddresses($basket, $errors, $localeKey); |
|
136 | + $this->copyServices($basket, $errors); |
|
137 | + $this->copyProducts($basket, $errors, $localeKey); |
|
138 | + $this->copyCoupons($basket, $errors, $localeKey); |
|
139 | 139 | |
140 | - $manager->setSession( $basket ); |
|
140 | + $manager->setSession($basket); |
|
141 | 141 | } |
142 | 142 | |
143 | - $session->set( 'aimeos/basket/locale', $localeKey ); |
|
143 | + $session->set('aimeos/basket/locale', $localeKey); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
@@ -152,20 +152,20 @@ discard block |
||
152 | 152 | * @param string $localeKey Unique identifier of the site, language and currency |
153 | 153 | * @return array Associative list of errors occured |
154 | 154 | */ |
155 | - protected function copyAddresses( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
155 | + protected function copyAddresses(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
156 | 156 | { |
157 | - foreach( $basket->getAddresses() as $type => $item ) |
|
157 | + foreach ($basket->getAddresses() as $type => $item) |
|
158 | 158 | { |
159 | 159 | try |
160 | 160 | { |
161 | - $this->setAddress( $type, $item->toArray() ); |
|
162 | - $basket->deleteAddress( $type ); |
|
161 | + $this->setAddress($type, $item->toArray()); |
|
162 | + $basket->deleteAddress($type); |
|
163 | 163 | } |
164 | - catch( \Exception $e ) |
|
164 | + catch (\Exception $e) |
|
165 | 165 | { |
166 | 166 | $logger = $this->getContext()->getLogger(); |
167 | 167 | $str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s'; |
168 | - $logger->log( sprintf( $str, $type, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
168 | + $logger->log(sprintf($str, $type, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
169 | 169 | $errors['address'][$type] = $e->getMessage(); |
170 | 170 | } |
171 | 171 | } |
@@ -182,20 +182,20 @@ discard block |
||
182 | 182 | * @param string $localeKey Unique identifier of the site, language and currency |
183 | 183 | * @return array Associative list of errors occured |
184 | 184 | */ |
185 | - protected function copyCoupons( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
185 | + protected function copyCoupons(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
186 | 186 | { |
187 | - foreach( $basket->getCoupons() as $code => $list ) |
|
187 | + foreach ($basket->getCoupons() as $code => $list) |
|
188 | 188 | { |
189 | 189 | try |
190 | 190 | { |
191 | - $this->addCoupon( $code ); |
|
192 | - $basket->deleteCoupon( $code, true ); |
|
191 | + $this->addCoupon($code); |
|
192 | + $basket->deleteCoupon($code, true); |
|
193 | 193 | } |
194 | - catch( \Exception $e ) |
|
194 | + catch (\Exception $e) |
|
195 | 195 | { |
196 | 196 | $logger = $this->getContext()->getLogger(); |
197 | 197 | $str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s'; |
198 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
198 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
199 | 199 | $errors['coupon'][$code] = $e->getMessage(); |
200 | 200 | } |
201 | 201 | } |
@@ -212,11 +212,11 @@ discard block |
||
212 | 212 | * @param string $localeKey Unique identifier of the site, language and currency |
213 | 213 | * @return array Associative list of errors occured |
214 | 214 | */ |
215 | - protected function copyProducts( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
215 | + protected function copyProducts(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
216 | 216 | { |
217 | - foreach( $basket->getProducts() as $pos => $product ) |
|
217 | + foreach ($basket->getProducts() as $pos => $product) |
|
218 | 218 | { |
219 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) { |
|
219 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) { |
|
220 | 220 | continue; |
221 | 221 | } |
222 | 222 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | { |
225 | 225 | $attrIds = array(); |
226 | 226 | |
227 | - foreach( $product->getAttributes() as $attrItem ) { |
|
227 | + foreach ($product->getAttributes() as $attrItem) { |
|
228 | 228 | $attrIds[$attrItem->getType()][] = $attrItem->getAttributeId(); |
229 | 229 | } |
230 | 230 | |
@@ -232,21 +232,21 @@ discard block |
||
232 | 232 | $product->getProductId(), |
233 | 233 | $product->getQuantity(), |
234 | 234 | array(), |
235 | - $this->getValue( $attrIds, 'variant', array() ), |
|
236 | - $this->getValue( $attrIds, 'config', array() ), |
|
237 | - $this->getValue( $attrIds, 'hidden', array() ), |
|
238 | - $this->getValue( $attrIds, 'custom', array() ), |
|
235 | + $this->getValue($attrIds, 'variant', array()), |
|
236 | + $this->getValue($attrIds, 'config', array()), |
|
237 | + $this->getValue($attrIds, 'hidden', array()), |
|
238 | + $this->getValue($attrIds, 'custom', array()), |
|
239 | 239 | $product->getStockType() |
240 | 240 | ); |
241 | 241 | |
242 | - $basket->deleteProduct( $pos ); |
|
242 | + $basket->deleteProduct($pos); |
|
243 | 243 | } |
244 | - catch( \Exception $e ) |
|
244 | + catch (\Exception $e) |
|
245 | 245 | { |
246 | 246 | $code = $product->getProductCode(); |
247 | 247 | $logger = $this->getContext()->getLogger(); |
248 | 248 | $str = 'Error migrating product with code "%1$s" in basket to locale "%2$s": %3$s'; |
249 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
249 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
250 | 250 | $errors['product'][$pos] = $e->getMessage(); |
251 | 251 | } |
252 | 252 | } |
@@ -262,22 +262,22 @@ discard block |
||
262 | 262 | * @param array $errors Associative list of previous errors |
263 | 263 | * @return array Associative list of errors occured |
264 | 264 | */ |
265 | - protected function copyServices( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors ) |
|
265 | + protected function copyServices(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors) |
|
266 | 266 | { |
267 | - foreach( $basket->getServices() as $type => $item ) |
|
267 | + foreach ($basket->getServices() as $type => $item) |
|
268 | 268 | { |
269 | 269 | try |
270 | 270 | { |
271 | 271 | $attributes = array(); |
272 | 272 | |
273 | - foreach( $item->getAttributes() as $attrItem ) { |
|
273 | + foreach ($item->getAttributes() as $attrItem) { |
|
274 | 274 | $attributes[$attrItem->getCode()] = $attrItem->getValue(); |
275 | 275 | } |
276 | 276 | |
277 | - $this->setService( $type, $item->getServiceId(), $attributes ); |
|
278 | - $basket->deleteService( $type ); |
|
277 | + $this->setService($type, $item->getServiceId(), $attributes); |
|
278 | + $basket->deleteService($type); |
|
279 | 279 | } |
280 | - catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically |
|
280 | + catch (\Exception $e) {; } // Don't notify the user as appropriate services can be added automatically |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | return $errors; |
@@ -292,31 +292,31 @@ discard block |
||
292 | 292 | * @return array List of items implementing \Aimeos\MShop\Attribute\Item\Iface |
293 | 293 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the actual attribute number doesn't match the expected one |
294 | 294 | */ |
295 | - protected function getAttributes( array $attributeIds, array $domains = array( 'price', 'text' ) ) |
|
295 | + protected function getAttributes(array $attributeIds, array $domains = array('price', 'text')) |
|
296 | 296 | { |
297 | - if( empty( $attributeIds ) ) { |
|
297 | + if (empty($attributeIds)) { |
|
298 | 298 | return array(); |
299 | 299 | } |
300 | 300 | |
301 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
301 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
302 | 302 | |
303 | - $search = $attributeManager->createSearch( true ); |
|
303 | + $search = $attributeManager->createSearch(true); |
|
304 | 304 | $expr = array( |
305 | - $search->compare( '==', 'attribute.id', $attributeIds ), |
|
305 | + $search->compare('==', 'attribute.id', $attributeIds), |
|
306 | 306 | $search->getConditions(), |
307 | 307 | ); |
308 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
309 | - $search->setSlice( 0, 0x7fffffff ); |
|
308 | + $search->setConditions($search->combine('&&', $expr)); |
|
309 | + $search->setSlice(0, 0x7fffffff); |
|
310 | 310 | |
311 | - $attrItems = $attributeManager->searchItems( $search, $domains ); |
|
311 | + $attrItems = $attributeManager->searchItems($search, $domains); |
|
312 | 312 | |
313 | - if( count( $attrItems ) !== count( $attributeIds ) ) |
|
313 | + if (count($attrItems) !== count($attributeIds)) |
|
314 | 314 | { |
315 | - $expected = implode( ',', $attributeIds ); |
|
316 | - $actual = implode( ',', array_keys( $attrItems ) ); |
|
317 | - $msg = sprintf( 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected ); |
|
315 | + $expected = implode(',', $attributeIds); |
|
316 | + $actual = implode(',', array_keys($attrItems)); |
|
317 | + $msg = sprintf('Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected); |
|
318 | 318 | |
319 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
319 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | return $attrItems; |
@@ -329,31 +329,31 @@ discard block |
||
329 | 329 | * @param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Item[] $orderAttributes List of order product attribute items |
330 | 330 | * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as key and attribute items as values |
331 | 331 | */ |
332 | - protected function getAttributeItems( array $orderAttributes ) |
|
332 | + protected function getAttributeItems(array $orderAttributes) |
|
333 | 333 | { |
334 | - if( empty( $orderAttributes ) ) { |
|
334 | + if (empty($orderAttributes)) { |
|
335 | 335 | return array(); |
336 | 336 | } |
337 | 337 | |
338 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
339 | - $search = $attributeManager->createSearch( true ); |
|
338 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
339 | + $search = $attributeManager->createSearch(true); |
|
340 | 340 | $expr = array(); |
341 | 341 | |
342 | - foreach( $orderAttributes as $item ) |
|
342 | + foreach ($orderAttributes as $item) |
|
343 | 343 | { |
344 | 344 | $tmp = array( |
345 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
346 | - $search->compare( '==', 'attribute.code', $item->getValue() ), |
|
347 | - $search->compare( '==', 'attribute.type.domain', 'product' ), |
|
348 | - $search->compare( '==', 'attribute.type.code', $item->getCode() ), |
|
349 | - $search->compare( '>', 'attribute.type.status', 0 ), |
|
345 | + $search->compare('==', 'attribute.domain', 'product'), |
|
346 | + $search->compare('==', 'attribute.code', $item->getValue()), |
|
347 | + $search->compare('==', 'attribute.type.domain', 'product'), |
|
348 | + $search->compare('==', 'attribute.type.code', $item->getCode()), |
|
349 | + $search->compare('>', 'attribute.type.status', 0), |
|
350 | 350 | $search->getConditions(), |
351 | 351 | ); |
352 | - $expr[] = $search->combine( '&&', $tmp ); |
|
352 | + $expr[] = $search->combine('&&', $tmp); |
|
353 | 353 | } |
354 | 354 | |
355 | - $search->setConditions( $search->combine( '||', $expr ) ); |
|
356 | - return $attributeManager->searchItems( $search, array( 'price' ) ); |
|
355 | + $search->setConditions($search->combine('||', $expr)); |
|
356 | + return $attributeManager->searchItems($search, array('price')); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | |
@@ -364,26 +364,26 @@ discard block |
||
364 | 364 | * @param string $code Code of the list type |
365 | 365 | * @return \Aimeos\MShop\Common\Item\Type\Iface List type item |
366 | 366 | */ |
367 | - protected function getProductListTypeItem( $domain, $code ) |
|
367 | + protected function getProductListTypeItem($domain, $code) |
|
368 | 368 | { |
369 | - if( !isset( $this->listTypeAttributes[$domain][$code] ) ) |
|
369 | + if (!isset($this->listTypeAttributes[$domain][$code])) |
|
370 | 370 | { |
371 | - $listTypeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists/type' ); |
|
371 | + $listTypeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists/type'); |
|
372 | 372 | |
373 | - $listTypeSearch = $listTypeManager->createSearch( true ); |
|
373 | + $listTypeSearch = $listTypeManager->createSearch(true); |
|
374 | 374 | $expr = array( |
375 | - $listTypeSearch->compare( '==', 'product.lists.type.domain', $domain ), |
|
376 | - $listTypeSearch->compare( '==', 'product.lists.type.code', $code ), |
|
375 | + $listTypeSearch->compare('==', 'product.lists.type.domain', $domain), |
|
376 | + $listTypeSearch->compare('==', 'product.lists.type.code', $code), |
|
377 | 377 | $listTypeSearch->getConditions(), |
378 | 378 | ); |
379 | - $listTypeSearch->setConditions( $listTypeSearch->combine( '&&', $expr ) ); |
|
379 | + $listTypeSearch->setConditions($listTypeSearch->combine('&&', $expr)); |
|
380 | 380 | |
381 | - $listTypeItems = $listTypeManager->searchItems( $listTypeSearch ); |
|
381 | + $listTypeItems = $listTypeManager->searchItems($listTypeSearch); |
|
382 | 382 | |
383 | - if( ( $listTypeItem = reset( $listTypeItems ) ) === false ) |
|
383 | + if (($listTypeItem = reset($listTypeItems)) === false) |
|
384 | 384 | { |
385 | - $msg = sprintf( 'List type for domain "%1$s" and code "%2$s" not found', $domain, $code ); |
|
386 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
385 | + $msg = sprintf('List type for domain "%1$s" and code "%2$s" not found', $domain, $code); |
|
386 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | $this->listTypeAttributes[$domain][$code] = $listTypeItem; |
@@ -401,43 +401,43 @@ discard block |
||
401 | 401 | * @param array $domains Names of the domain items that should be fetched too |
402 | 402 | * @return array List of products matching the given attributes |
403 | 403 | */ |
404 | - protected function getProductVariants( \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
405 | - array $domains = array( 'attribute', 'media', 'price', 'text' ) ) |
|
404 | + protected function getProductVariants(\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
405 | + array $domains = array('attribute', 'media', 'price', 'text')) |
|
406 | 406 | { |
407 | 407 | $subProductIds = array(); |
408 | - foreach( $productItem->getRefItems( 'product', 'default', 'default' ) as $item ) { |
|
408 | + foreach ($productItem->getRefItems('product', 'default', 'default') as $item) { |
|
409 | 409 | $subProductIds[] = $item->getId(); |
410 | 410 | } |
411 | 411 | |
412 | - if( count( $subProductIds ) === 0 ) { |
|
412 | + if (count($subProductIds) === 0) { |
|
413 | 413 | return array(); |
414 | 414 | } |
415 | 415 | |
416 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
417 | - $search = $productManager->createSearch( true ); |
|
416 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
417 | + $search = $productManager->createSearch(true); |
|
418 | 418 | |
419 | 419 | $expr = array( |
420 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
420 | + $search->compare('==', 'product.id', $subProductIds), |
|
421 | 421 | $search->getConditions(), |
422 | 422 | ); |
423 | 423 | |
424 | - if( count( $variantAttributeIds ) > 0 ) |
|
424 | + if (count($variantAttributeIds) > 0) |
|
425 | 425 | { |
426 | - foreach( $variantAttributeIds as $key => $id ) { |
|
426 | + foreach ($variantAttributeIds as $key => $id) { |
|
427 | 427 | $variantAttributeIds[$key] = (string) $id; |
428 | 428 | } |
429 | 429 | |
430 | - $listTypeItem = $this->getProductListTypeItem( 'attribute', 'variant' ); |
|
430 | + $listTypeItem = $this->getProductListTypeItem('attribute', 'variant'); |
|
431 | 431 | |
432 | - $param = array( 'attribute', $listTypeItem->getId(), $variantAttributeIds ); |
|
433 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
432 | + $param = array('attribute', $listTypeItem->getId(), $variantAttributeIds); |
|
433 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
434 | 434 | |
435 | - $expr[] = $search->compare( '==', $cmpfunc, count( $variantAttributeIds ) ); |
|
435 | + $expr[] = $search->compare('==', $cmpfunc, count($variantAttributeIds)); |
|
436 | 436 | } |
437 | 437 | |
438 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
438 | + $search->setConditions($search->combine('&&', $expr)); |
|
439 | 439 | |
440 | - return $productManager->searchItems( $search, $domains ); |
|
440 | + return $productManager->searchItems($search, $domains); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | |
@@ -449,9 +449,9 @@ discard block |
||
449 | 449 | * @param mixed $default Default value if no value is available for the given name |
450 | 450 | * @return mixed Value from the array or default value |
451 | 451 | */ |
452 | - protected function getValue( array $values, $name, $default = null ) |
|
452 | + protected function getValue(array $values, $name, $default = null) |
|
453 | 453 | { |
454 | - if( isset( $values[$name] ) ) { |
|
454 | + if (isset($values[$name])) { |
|
455 | 455 | return $values[$name]; |
456 | 456 | } |
457 | 457 | |
@@ -466,24 +466,24 @@ discard block |
||
466 | 466 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If product is not associated to at least one category |
467 | 467 | * @deprecated 2016.05 |
468 | 468 | */ |
469 | - protected function checkCategory( $prodid ) |
|
469 | + protected function checkCategory($prodid) |
|
470 | 470 | { |
471 | - $catalogListManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' ); |
|
471 | + $catalogListManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists'); |
|
472 | 472 | |
473 | - $search = $catalogListManager->createSearch( true ); |
|
473 | + $search = $catalogListManager->createSearch(true); |
|
474 | 474 | $expr = array( |
475 | - $search->compare( '==', 'catalog.lists.refid', $prodid ), |
|
475 | + $search->compare('==', 'catalog.lists.refid', $prodid), |
|
476 | 476 | $search->getConditions() |
477 | 477 | ); |
478 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
479 | - $search->setSlice( 0, 1 ); |
|
478 | + $search->setConditions($search->combine('&&', $expr)); |
|
479 | + $search->setSlice(0, 1); |
|
480 | 480 | |
481 | - $result = $catalogListManager->searchItems( $search ); |
|
481 | + $result = $catalogListManager->searchItems($search); |
|
482 | 482 | |
483 | - if( reset( $result ) === false ) |
|
483 | + if (reset($result) === false) |
|
484 | 484 | { |
485 | - $msg = sprintf( 'Adding product with ID "%1$s" is not allowed', $prodid ); |
|
486 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
485 | + $msg = sprintf('Adding product with ID "%1$s" is not allowed', $prodid); |
|
486 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | |
@@ -495,35 +495,35 @@ discard block |
||
495 | 495 | * @param string $stocktype Unique code of the stock type |
496 | 496 | * @return integer|null Number of available items in stock (null for unlimited stock) |
497 | 497 | */ |
498 | - protected function getStockLevel( $prodid, $stocktype ) |
|
498 | + protected function getStockLevel($prodid, $stocktype) |
|
499 | 499 | { |
500 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/stock' ); |
|
500 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/stock'); |
|
501 | 501 | |
502 | - $search = $manager->createSearch( true ); |
|
502 | + $search = $manager->createSearch(true); |
|
503 | 503 | $expr = array( |
504 | - $search->compare( '==', 'product.stock.parentid', $prodid ), |
|
504 | + $search->compare('==', 'product.stock.parentid', $prodid), |
|
505 | 505 | $search->getConditions(), |
506 | - $search->compare( '==', 'product.stock.type.code', $stocktype ), |
|
506 | + $search->compare('==', 'product.stock.type.code', $stocktype), |
|
507 | 507 | ); |
508 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
508 | + $search->setConditions($search->combine('&&', $expr)); |
|
509 | 509 | |
510 | - $result = $manager->searchItems( $search ); |
|
510 | + $result = $manager->searchItems($search); |
|
511 | 511 | |
512 | - if( empty( $result ) ) |
|
512 | + if (empty($result)) |
|
513 | 513 | { |
514 | - $msg = sprintf( 'No stock for product ID "%1$s" and type "%2$s" available', $prodid, $stocktype ); |
|
515 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
514 | + $msg = sprintf('No stock for product ID "%1$s" and type "%2$s" available', $prodid, $stocktype); |
|
515 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | $stocklevel = null; |
519 | 519 | |
520 | - foreach( $result as $item ) |
|
520 | + foreach ($result as $item) |
|
521 | 521 | { |
522 | - if( ( $stock = $item->getStockLevel() ) === null ) { |
|
522 | + if (($stock = $item->getStockLevel()) === null) { |
|
523 | 523 | return null; |
524 | 524 | } |
525 | 525 | |
526 | - $stocklevel = max( (int) $stocklevel, $item->getStockLevel() ); |
|
526 | + $stocklevel = max((int) $stocklevel, $item->getStockLevel()); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | return $stocklevel; |
@@ -4,7 +4,7 @@ |
||
4 | 4 | 'frontend' => array( |
5 | 5 | 'basket' => array( |
6 | 6 | 'decorators' => array( |
7 | - 'local' => array( 'Category' ), |
|
7 | + 'local' => array('Category'), |
|
8 | 8 | ), |
9 | 9 | ), |
10 | 10 | ), |
@@ -15,15 +15,15 @@ discard block |
||
15 | 15 | public static function bootstrap() |
16 | 16 | { |
17 | 17 | self::getAimeos(); |
18 | - \Aimeos\MShop\Factory::setCache( false ); |
|
19 | - \Aimeos\Controller\Frontend\Factory::setCache( false ); |
|
18 | + \Aimeos\MShop\Factory::setCache(false); |
|
19 | + \Aimeos\Controller\Frontend\Factory::setCache(false); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
23 | - public static function getContext( $site = 'unittest' ) |
|
23 | + public static function getContext($site = 'unittest') |
|
24 | 24 | { |
25 | - if( !isset( self::$context[$site] ) ) { |
|
26 | - self::$context[$site] = self::createContext( $site ); |
|
25 | + if (!isset(self::$context[$site])) { |
|
26 | + self::$context[$site] = self::createContext($site); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | return clone self::$context[$site]; |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | |
33 | 33 | private static function getAimeos() |
34 | 34 | { |
35 | - if( !isset( self::$aimeos ) ) |
|
35 | + if (!isset(self::$aimeos)) |
|
36 | 36 | { |
37 | 37 | require_once 'Bootstrap.php'; |
38 | - spl_autoload_register( 'Aimeos\\Bootstrap::autoload' ); |
|
38 | + spl_autoload_register('Aimeos\\Bootstrap::autoload'); |
|
39 | 39 | |
40 | - $extdir = dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ); |
|
41 | - self::$aimeos = new \Aimeos\Bootstrap( array( $extdir ), true ); |
|
40 | + $extdir = dirname(dirname(dirname(dirname(dirname(__FILE__))))); |
|
41 | + self::$aimeos = new \Aimeos\Bootstrap(array($extdir), true); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | return self::$aimeos; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | /** |
49 | 49 | * @param string $site |
50 | 50 | */ |
51 | - private static function createContext( $site ) |
|
51 | + private static function createContext($site) |
|
52 | 52 | { |
53 | 53 | $ctx = new \Aimeos\MShop\Context\Item\Standard(); |
54 | 54 | $aimeos = self::getAimeos(); |
@@ -58,34 +58,34 @@ discard block |
||
58 | 58 | $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config'; |
59 | 59 | $file = __DIR__ . DIRECTORY_SEPARATOR . 'confdoc.ser'; |
60 | 60 | |
61 | - $conf = new \Aimeos\MW\Config\PHPArray( array(), $paths ); |
|
62 | - $conf = new \Aimeos\MW\Config\Decorator\Memory( $conf ); |
|
63 | - $conf = new \Aimeos\MW\Config\Decorator\Documentor( $conf, $file ); |
|
64 | - $ctx->setConfig( $conf ); |
|
61 | + $conf = new \Aimeos\MW\Config\PHPArray(array(), $paths); |
|
62 | + $conf = new \Aimeos\MW\Config\Decorator\Memory($conf); |
|
63 | + $conf = new \Aimeos\MW\Config\Decorator\Documentor($conf, $file); |
|
64 | + $ctx->setConfig($conf); |
|
65 | 65 | |
66 | 66 | |
67 | - $dbm = new \Aimeos\MW\DB\Manager\PDO( $conf ); |
|
68 | - $ctx->setDatabaseManager( $dbm ); |
|
67 | + $dbm = new \Aimeos\MW\DB\Manager\PDO($conf); |
|
68 | + $ctx->setDatabaseManager($dbm); |
|
69 | 69 | |
70 | 70 | |
71 | - $logger = new \Aimeos\MW\Logger\File( 'unittest.log', \Aimeos\MW\Logger\Base::DEBUG ); |
|
72 | - $ctx->setLogger( $logger ); |
|
71 | + $logger = new \Aimeos\MW\Logger\File('unittest.log', \Aimeos\MW\Logger\Base::DEBUG); |
|
72 | + $ctx->setLogger($logger); |
|
73 | 73 | |
74 | 74 | |
75 | - $i18n = new \Aimeos\MW\Translation\None( 'de' ); |
|
76 | - $ctx->setI18n( array( 'de' => $i18n ) ); |
|
75 | + $i18n = new \Aimeos\MW\Translation\None('de'); |
|
76 | + $ctx->setI18n(array('de' => $i18n)); |
|
77 | 77 | |
78 | 78 | |
79 | 79 | $session = new \Aimeos\MW\Session\None(); |
80 | - $ctx->setSession( $session ); |
|
80 | + $ctx->setSession($session); |
|
81 | 81 | |
82 | 82 | |
83 | - $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $ctx ); |
|
84 | - $locale = $localeManager->bootstrap( $site, '', '', false ); |
|
85 | - $ctx->setLocale( $locale ); |
|
83 | + $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx); |
|
84 | + $locale = $localeManager->bootstrap($site, '', '', false); |
|
85 | + $ctx->setLocale($locale); |
|
86 | 86 | |
87 | 87 | |
88 | - $ctx->setEditor( 'core:controller/frontend' ); |
|
88 | + $ctx->setEditor('core:controller/frontend'); |
|
89 | 89 | |
90 | 90 | return $ctx; |
91 | 91 | } |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | * @param string $name Name of the manager |
26 | 26 | * @return \Aimeos\MShop\Common\Manager\Iface Manager object |
27 | 27 | */ |
28 | - public function createManager( $name ) |
|
28 | + public function createManager($name) |
|
29 | 29 | { |
30 | - return $this->getController()->createManager( $name ); |
|
30 | + return $this->getController()->createManager($name); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * @return array Associative list of items implementing \Aimeos\MShop\Catalog\Item\Iface with their IDs as keys |
53 | 53 | * @since 2015.08 |
54 | 54 | */ |
55 | - public function getCatalogPath( $id, array $domains = array( 'text', 'media' ) ) |
|
55 | + public function getCatalogPath($id, array $domains = array('text', 'media')) |
|
56 | 56 | { |
57 | - return $this->getController()->getCatalogPath( $id, $domains ); |
|
57 | + return $this->getController()->getCatalogPath($id, $domains); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | * @return \Aimeos\MShop\Catalog\Item\Iface Catalog node, maybe with children depending on the level constant |
70 | 70 | * @since 2015.08 |
71 | 71 | */ |
72 | - public function getCatalogTree( $id = null, array $domains = array( 'text', 'media' ), |
|
73 | - $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE, \Aimeos\MW\Criteria\Iface $search = null ) |
|
72 | + public function getCatalogTree($id = null, array $domains = array('text', 'media'), |
|
73 | + $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE, \Aimeos\MW\Criteria\Iface $search = null) |
|
74 | 74 | { |
75 | - return $this->getController()->getCatalogTree( $id, $domains, $level, $search ); |
|
75 | + return $this->getController()->getCatalogTree($id, $domains, $level, $search); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | * @return array Associative list of key values as key and the product count for this key as value |
85 | 85 | * @since 2015.08 |
86 | 86 | */ |
87 | - public function aggregateIndex( \Aimeos\MW\Criteria\Iface $filter, $key ) |
|
87 | + public function aggregateIndex(\Aimeos\MW\Criteria\Iface $filter, $key) |
|
88 | 88 | { |
89 | - return $this->getController()->aggregateIndex( $filter, $key ); |
|
89 | + return $this->getController()->aggregateIndex($filter, $key); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
99 | 99 | * @since 2015.08 |
100 | 100 | */ |
101 | - public function addIndexFilterCategory( \Aimeos\MW\Criteria\Iface $search, $catid ) |
|
101 | + public function addIndexFilterCategory(\Aimeos\MW\Criteria\Iface $search, $catid) |
|
102 | 102 | { |
103 | - return $this->getController()->addIndexFilterCategory( $search, $catid ); |
|
103 | + return $this->getController()->addIndexFilterCategory($search, $catid); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
114 | 114 | * @since 2015.08 |
115 | 115 | */ |
116 | - public function addIndexFilterText( \Aimeos\MW\Criteria\Iface $search, $input, $listtype = 'default' ) |
|
116 | + public function addIndexFilterText(\Aimeos\MW\Criteria\Iface $search, $input, $listtype = 'default') |
|
117 | 117 | { |
118 | - return $this->getController()->addIndexFilterText( $search, $input, $listtype ); |
|
118 | + return $this->getController()->addIndexFilterText($search, $input, $listtype); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
131 | 131 | * @since 2015.08 |
132 | 132 | */ |
133 | - public function createIndexFilter( $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' ) |
|
133 | + public function createIndexFilter($sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default') |
|
134 | 134 | { |
135 | - return $this->getController()->createIndexFilter( $sort, $direction, $start, $size, $listtype ); |
|
135 | + return $this->getController()->createIndexFilter($sort, $direction, $start, $size, $listtype); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
149 | 149 | * @since 2015.08 |
150 | 150 | */ |
151 | - public function createIndexFilterCategory( $catid, $sort = 'position', $direction = 'asc', $start = 0, $size = 100, $listtype = 'default' ) |
|
151 | + public function createIndexFilterCategory($catid, $sort = 'position', $direction = 'asc', $start = 0, $size = 100, $listtype = 'default') |
|
152 | 152 | { |
153 | - return $this->getController()->createIndexFilter( $catid, $sort, $direction, $start, $size, $listtype ); |
|
153 | + return $this->getController()->createIndexFilter($catid, $sort, $direction, $start, $size, $listtype); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
167 | 167 | * @since 2015.08 |
168 | 168 | */ |
169 | - public function createIndexFilterText( $input, $sort = 'relevance', $direction = 'asc', $start = 0, $size = 100, $listtype = 'default' ) |
|
169 | + public function createIndexFilterText($input, $sort = 'relevance', $direction = 'asc', $start = 0, $size = 100, $listtype = 'default') |
|
170 | 170 | { |
171 | - return $this->getController()->createIndexFilter( $input, $sort, $direction, $start, $size, $listtype ); |
|
171 | + return $this->getController()->createIndexFilter($input, $sort, $direction, $start, $size, $listtype); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface |
182 | 182 | * @since 2015.08 |
183 | 183 | */ |
184 | - public function getIndexItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null ) |
|
184 | + public function getIndexItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null) |
|
185 | 185 | { |
186 | - return $this->getController()->getIndexItems( $filter, $domains, $total ); |
|
186 | + return $this->getController()->getIndexItems($filter, $domains, $total); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | * @return array List of product items implementing \Aimeos\MShop\Product\Item\Iface |
196 | 196 | * @since 2015.08 |
197 | 197 | */ |
198 | - public function getProductItems( array $ids, array $domains = array( 'media', 'price', 'text' ) ) |
|
198 | + public function getProductItems(array $ids, array $domains = array('media', 'price', 'text')) |
|
199 | 199 | { |
200 | - return $this->getController()->getProductItems( $ids, $domains ); |
|
200 | + return $this->getController()->getProductItems($ids, $domains); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | |
@@ -213,9 +213,9 @@ discard block |
||
213 | 213 | * @param string $type Type of the text like "name", "short", "long", etc. |
214 | 214 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
215 | 215 | */ |
216 | - public function createTextFilter( $input, $sort = null, $direction = 'desc', $start = 0, $size = 25, $listtype = 'default', $type = 'name' ) |
|
216 | + public function createTextFilter($input, $sort = null, $direction = 'desc', $start = 0, $size = 25, $listtype = 'default', $type = 'name') |
|
217 | 217 | { |
218 | - return $this->getController()->createTextFilter( $input, $sort, $direction, $start, $size, $listtype, $type ); |
|
218 | + return $this->getController()->createTextFilter($input, $sort, $direction, $start, $size, $listtype, $type); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | * @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions |
226 | 226 | * @return array Associative list of the product ID as key and the product text as value |
227 | 227 | */ |
228 | - public function getTextList( \Aimeos\MW\Criteria\Iface $filter ) |
|
228 | + public function getTextList(\Aimeos\MW\Criteria\Iface $filter) |
|
229 | 229 | { |
230 | - return $this->getController()->getTextList( $filter ); |
|
230 | + return $this->getController()->getTextList($filter); |
|
231 | 231 | } |
232 | 232 | } |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | * @param array $ref List of domains for which the items referenced by the services should be fetched too |
28 | 28 | * @return array List of service items implementing \Aimeos\MShop\Service\Item\Iface with referenced items |
29 | 29 | */ |
30 | - public function getServices( $type, \Aimeos\MShop\Order\Item\Base\Iface $basket, |
|
31 | - $ref = array( 'media', 'price', 'text' ) ) |
|
30 | + public function getServices($type, \Aimeos\MShop\Order\Item\Base\Iface $basket, |
|
31 | + $ref = array('media', 'price', 'text')) |
|
32 | 32 | { |
33 | - return $this->getController()->getServices( $type, $basket, $ref ); |
|
33 | + return $this->getController()->getServices($type, $basket, $ref); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object |
44 | 44 | * @return array List of attribute definitions implementing \Aimeos\MW\Criteria\Attribute\Iface |
45 | 45 | */ |
46 | - public function getServiceAttributes( $type, $serviceId, \Aimeos\MShop\Order\Item\Base\Iface $basket ) |
|
46 | + public function getServiceAttributes($type, $serviceId, \Aimeos\MShop\Order\Item\Base\Iface $basket) |
|
47 | 47 | { |
48 | - return $this->getController()->getServiceAttributes( $type, $serviceId, $basket ); |
|
48 | + return $this->getController()->getServiceAttributes($type, $serviceId, $basket); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | * @throws \Aimeos\MShop\Exception If service provider isn't available |
61 | 61 | * @throws \Exception If an error occurs |
62 | 62 | */ |
63 | - public function getServicePrice( $type, $serviceId, \Aimeos\MShop\Order\Item\Base\Iface $basket ) |
|
63 | + public function getServicePrice($type, $serviceId, \Aimeos\MShop\Order\Item\Base\Iface $basket) |
|
64 | 64 | { |
65 | - return $this->getController()->getServicePrice( $type, $serviceId, $basket ); |
|
65 | + return $this->getController()->getServicePrice($type, $serviceId, $basket); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | * @return array List of key/value pairs of attributes keys and an error message for values that are invalid or |
77 | 77 | * missing |
78 | 78 | */ |
79 | - public function checkServiceAttributes( $type, $serviceId, array $attributes ) |
|
79 | + public function checkServiceAttributes($type, $serviceId, array $attributes) |
|
80 | 80 | { |
81 | - return $this->getController()->checkServiceAttributes( $type, $serviceId, $attributes ); |
|
81 | + return $this->getController()->checkServiceAttributes($type, $serviceId, $attributes); |
|
82 | 82 | } |
83 | 83 | } |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object to be stored |
30 | 30 | * @return \Aimeos\MShop\Order\Item\Iface Order item that belongs to the stored basket |
31 | 31 | */ |
32 | - public function store( \Aimeos\MShop\Order\Item\Base\Iface $basket ) |
|
32 | + public function store(\Aimeos\MShop\Order\Item\Base\Iface $basket) |
|
33 | 33 | { |
34 | - return $this->getController()->store( $basket ); |
|
34 | + return $this->getController()->store($basket); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | * @param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object |
55 | 55 | * @return void |
56 | 56 | */ |
57 | - public function block( \Aimeos\MShop\Order\Item\Iface $orderItem ) |
|
57 | + public function block(\Aimeos\MShop\Order\Item\Iface $orderItem) |
|
58 | 58 | { |
59 | - $this->getController()->block( $orderItem ); |
|
59 | + $this->getController()->block($orderItem); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * @param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object |
80 | 80 | * @return void |
81 | 81 | */ |
82 | - public function unblock( \Aimeos\MShop\Order\Item\Iface $orderItem ) |
|
82 | + public function unblock(\Aimeos\MShop\Order\Item\Iface $orderItem) |
|
83 | 83 | { |
84 | - $this->getController()->unblock( $orderItem ); |
|
84 | + $this->getController()->unblock($orderItem); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | * @param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object |
101 | 101 | * @return void |
102 | 102 | */ |
103 | - public function update( \Aimeos\MShop\Order\Item\Iface $orderItem ) |
|
103 | + public function update(\Aimeos\MShop\Order\Item\Iface $orderItem) |
|
104 | 104 | { |
105 | - $this->getController()->update( $orderItem ); |
|
105 | + $this->getController()->update($orderItem); |
|
106 | 106 | } |
107 | 107 | } |
@@ -296,17 +296,14 @@ discard block |
||
296 | 296 | { |
297 | 297 | $address->copyFrom( $value ); |
298 | 298 | $this->basket->setAddress( $address, $type ); |
299 | - } |
|
300 | - else if( is_array( $value ) ) |
|
299 | + } else if( is_array( $value ) ) |
|
301 | 300 | { |
302 | 301 | $this->setAddressFromArray( $address, $value ); |
303 | 302 | $this->basket->setAddress( $address, $type ); |
304 | - } |
|
305 | - else if( $value === null ) |
|
303 | + } else if( $value === null ) |
|
306 | 304 | { |
307 | 305 | $this->basket->deleteAddress( $type ); |
308 | - } |
|
309 | - else |
|
306 | + } else |
|
310 | 307 | { |
311 | 308 | throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Invalid value for address type "%1$s"', $type ) ); |
312 | 309 | } |
@@ -446,8 +443,7 @@ discard block |
||
446 | 443 | $orderBaseProductItem->setQuantity( $stocklevel ); |
447 | 444 | $this->get()->addProduct( $orderBaseProductItem, $position ); |
448 | 445 | } |
449 | - } |
|
450 | - catch( \Aimeos\MShop\Order\Exception $e ) {} // hide error if product position changed by plugin |
|
446 | + } catch( \Aimeos\MShop\Order\Exception $e ) {} // hide error if product position changed by plugin |
|
451 | 447 | } |
452 | 448 | |
453 | 449 | if( $stocklevel !== null && $stocklevel < $quantity ) |
@@ -596,10 +592,11 @@ discard block |
||
596 | 592 | { |
597 | 593 | $msg = sprintf( 'No unique article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
598 | 594 | throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
599 | - } |
|
600 | - else if( ( $result = reset( $productItems ) ) !== false ) // count == 1 |
|
595 | + } else if( ( $result = reset( $productItems ) ) !== false ) { |
|
596 | + // count == 1 |
|
601 | 597 | { |
602 | 598 | $productItem = $result; |
599 | + } |
|
603 | 600 | $orderBaseProductItem->setProductCode( $productItem->getCode() ); |
604 | 601 | |
605 | 602 | $subprices = $productItem->getRefItems( 'price', 'default', 'default' ); |
@@ -619,10 +616,11 @@ discard block |
||
619 | 616 | |
620 | 617 | $attr[] = $orderAttributeItem; |
621 | 618 | } |
622 | - } |
|
623 | - else if( !isset( $options['variant'] ) || $options['variant'] != false ) // count == 0 |
|
619 | + } else if( !isset( $options['variant'] ) || $options['variant'] != false ) { |
|
620 | + // count == 0 |
|
624 | 621 | { |
625 | 622 | $msg = sprintf( 'No article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
623 | + } |
|
626 | 624 | throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
627 | 625 | } |
628 | 626 |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | * @param \Aimeos\MShop\Context\Item\Iface $context Object storing the required instances for manaing databases |
33 | 33 | * connections, logger, session, etc. |
34 | 34 | */ |
35 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
|
35 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context) |
|
36 | 36 | { |
37 | - parent::__construct( $context ); |
|
37 | + parent::__construct($context); |
|
38 | 38 | |
39 | - $this->domainManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
39 | + $this->domainManager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
40 | 40 | $this->basket = $this->domainManager->getSession(); |
41 | 41 | |
42 | 42 | $this->checkLocale(); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | public function clear() |
50 | 50 | { |
51 | 51 | $this->basket = $this->domainManager->createItem(); |
52 | - $this->domainManager->setSession( $this->basket ); |
|
52 | + $this->domainManager->setSession($this->basket); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function save() |
71 | 71 | { |
72 | - if( $this->basket->isModified() ) { |
|
73 | - $this->domainManager->setSession( $this->basket ); |
|
72 | + if ($this->basket->isModified()) { |
|
73 | + $this->domainManager->setSession($this->basket); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
@@ -95,48 +95,48 @@ discard block |
||
95 | 95 | * @param string $stocktype Unique code of the stock type to deliver the products from |
96 | 96 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
97 | 97 | */ |
98 | - public function addProduct( $prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
98 | + public function addProduct($prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
99 | 99 | array $configAttributeIds = array(), array $hiddenAttributeIds = array(), array $customAttributeValues = array(), |
100 | - $stocktype = 'default' ) |
|
100 | + $stocktype = 'default') |
|
101 | 101 | { |
102 | 102 | $context = $this->getContext(); |
103 | 103 | |
104 | - $productItem = $this->getDomainItem( 'product', 'product.id', $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ) ); |
|
104 | + $productItem = $this->getDomainItem('product', 'product.id', $prodid, array('media', 'supplier', 'price', 'product', 'text')); |
|
105 | 105 | |
106 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
107 | - $orderBaseProductItem->copyFrom( $productItem ); |
|
108 | - $orderBaseProductItem->setQuantity( $quantity ); |
|
109 | - $orderBaseProductItem->setStockType( $stocktype ); |
|
106 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
107 | + $orderBaseProductItem->copyFrom($productItem); |
|
108 | + $orderBaseProductItem->setQuantity($quantity); |
|
109 | + $orderBaseProductItem->setStockType($stocktype); |
|
110 | 110 | |
111 | 111 | $attr = array(); |
112 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
112 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
113 | 113 | |
114 | - switch( $productItem->getType() ) |
|
114 | + switch ($productItem->getType()) |
|
115 | 115 | { |
116 | 116 | case 'select': |
117 | - $attr = $this->getVariantDetails( $orderBaseProductItem, $productItem, $prices, $variantAttributeIds, $options ); |
|
117 | + $attr = $this->getVariantDetails($orderBaseProductItem, $productItem, $prices, $variantAttributeIds, $options); |
|
118 | 118 | break; |
119 | 119 | case 'bundle': |
120 | - $this->addBundleProducts( $orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype ); |
|
120 | + $this->addBundleProducts($orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype); |
|
121 | 121 | break; |
122 | 122 | } |
123 | 123 | |
124 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
125 | - $price = $priceManager->getLowestPrice( $prices, $quantity ); |
|
124 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
125 | + $price = $priceManager->getLowestPrice($prices, $quantity); |
|
126 | 126 | |
127 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, $configAttributeIds, 'config' ) ); |
|
128 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, $hiddenAttributeIds, 'hidden' ) ); |
|
129 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, array_keys( $customAttributeValues ), 'custom', $customAttributeValues ) ); |
|
127 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, $configAttributeIds, 'config')); |
|
128 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, $hiddenAttributeIds, 'hidden')); |
|
129 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, array_keys($customAttributeValues), 'custom', $customAttributeValues)); |
|
130 | 130 | |
131 | 131 | // remove product rebate of original price in favor to rebates granted for the order |
132 | - $price->setRebate( '0.00' ); |
|
132 | + $price->setRebate('0.00'); |
|
133 | 133 | |
134 | - $orderBaseProductItem->setPrice( $price ); |
|
135 | - $orderBaseProductItem->setAttributes( $attr ); |
|
134 | + $orderBaseProductItem->setPrice($price); |
|
135 | + $orderBaseProductItem->setAttributes($attr); |
|
136 | 136 | |
137 | - $this->addProductInStock( $orderBaseProductItem, $productItem->getId(), $quantity, $options, $stocktype ); |
|
137 | + $this->addProductInStock($orderBaseProductItem, $productItem->getId(), $quantity, $options, $stocktype); |
|
138 | 138 | |
139 | - $this->domainManager->setSession( $this->basket ); |
|
139 | + $this->domainManager->setSession($this->basket); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | |
@@ -145,18 +145,18 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @param integer $position Position number (key) of the order product item |
147 | 147 | */ |
148 | - public function deleteProduct( $position ) |
|
148 | + public function deleteProduct($position) |
|
149 | 149 | { |
150 | - $product = $this->basket->getProduct( $position ); |
|
150 | + $product = $this->basket->getProduct($position); |
|
151 | 151 | |
152 | - if( $product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
152 | + if ($product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
153 | 153 | { |
154 | - $msg = sprintf( 'Basket item at position "%1$d" cannot be deleted manually', $position ); |
|
155 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
154 | + $msg = sprintf('Basket item at position "%1$d" cannot be deleted manually', $position); |
|
155 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
156 | 156 | } |
157 | 157 | |
158 | - $this->basket->deleteProduct( $position ); |
|
159 | - $this->domainManager->setSession( $this->basket ); |
|
158 | + $this->basket->deleteProduct($position); |
|
159 | + $this->domainManager->setSession($this->basket); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
@@ -169,35 +169,35 @@ discard block |
||
169 | 169 | * The 'stock'=>false option allows adding products without being in stock. |
170 | 170 | * @param string[] $configAttributeCodes Codes of the product config attributes that should be REMOVED |
171 | 171 | */ |
172 | - public function editProduct( $position, $quantity, array $options = array(), |
|
173 | - array $configAttributeCodes = array() ) |
|
172 | + public function editProduct($position, $quantity, array $options = array(), |
|
173 | + array $configAttributeCodes = array()) |
|
174 | 174 | { |
175 | - $product = $this->basket->getProduct( $position ); |
|
176 | - $product->setQuantity( $quantity ); // Enforce check immediately |
|
175 | + $product = $this->basket->getProduct($position); |
|
176 | + $product->setQuantity($quantity); // Enforce check immediately |
|
177 | 177 | |
178 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
178 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
179 | 179 | { |
180 | - $msg = sprintf( 'Basket item at position "%1$d" cannot be changed', $position ); |
|
181 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
180 | + $msg = sprintf('Basket item at position "%1$d" cannot be changed', $position); |
|
181 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | $attributes = $product->getAttributes(); |
185 | - foreach( $attributes as $key => $attribute ) |
|
185 | + foreach ($attributes as $key => $attribute) |
|
186 | 186 | { |
187 | - if( in_array( $attribute->getCode(), $configAttributeCodes ) ) { |
|
188 | - unset( $attributes[$key] ); |
|
187 | + if (in_array($attribute->getCode(), $configAttributeCodes)) { |
|
188 | + unset($attributes[$key]); |
|
189 | 189 | } |
190 | 190 | } |
191 | - $product->setAttributes( $attributes ); |
|
191 | + $product->setAttributes($attributes); |
|
192 | 192 | |
193 | - $productItem = $this->getDomainItem( 'product', 'product.code', $product->getProductCode(), array( 'price', 'text' ) ); |
|
194 | - $prices = $productItem->getRefItems( 'price', 'default' ); |
|
193 | + $productItem = $this->getDomainItem('product', 'product.code', $product->getProductCode(), array('price', 'text')); |
|
194 | + $prices = $productItem->getRefItems('price', 'default'); |
|
195 | 195 | |
196 | - $product->setPrice( $this->calcPrice( $product, $prices, $quantity ) ); |
|
196 | + $product->setPrice($this->calcPrice($product, $prices, $quantity)); |
|
197 | 197 | |
198 | - $this->editProductInStock( $product, $productItem, $quantity, $position, $options ); |
|
198 | + $this->editProductInStock($product, $productItem, $quantity, $position, $options); |
|
199 | 199 | |
200 | - $this->domainManager->setSession( $this->basket ); |
|
200 | + $this->domainManager->setSession($this->basket); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | |
@@ -207,50 +207,50 @@ discard block |
||
207 | 207 | * @param string $code Coupon code entered by the user |
208 | 208 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
209 | 209 | */ |
210 | - public function addCoupon( $code ) |
|
210 | + public function addCoupon($code) |
|
211 | 211 | { |
212 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
213 | - $codeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon/code' ); |
|
212 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
213 | + $codeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon/code'); |
|
214 | 214 | |
215 | 215 | |
216 | - $search = $codeManager->createSearch( true ); |
|
216 | + $search = $codeManager->createSearch(true); |
|
217 | 217 | $expr = array( |
218 | - $search->compare( '==', 'coupon.code.code', $code ), |
|
218 | + $search->compare('==', 'coupon.code.code', $code), |
|
219 | 219 | $search->getConditions(), |
220 | 220 | ); |
221 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
222 | - $search->setSlice( 0, 1 ); |
|
221 | + $search->setConditions($search->combine('&&', $expr)); |
|
222 | + $search->setSlice(0, 1); |
|
223 | 223 | |
224 | - $result = $codeManager->searchItems( $search ); |
|
224 | + $result = $codeManager->searchItems($search); |
|
225 | 225 | |
226 | - if( ( $codeItem = reset( $result ) ) === false ) { |
|
227 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon code "%1$s" is invalid or not available any more', $code ) ); |
|
226 | + if (($codeItem = reset($result)) === false) { |
|
227 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon code "%1$s" is invalid or not available any more', $code)); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | |
231 | - $search = $manager->createSearch( true ); |
|
231 | + $search = $manager->createSearch(true); |
|
232 | 232 | $expr = array( |
233 | - $search->compare( '==', 'coupon.id', $codeItem->getParentId() ), |
|
233 | + $search->compare('==', 'coupon.id', $codeItem->getParentId()), |
|
234 | 234 | $search->getConditions(), |
235 | 235 | ); |
236 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
237 | - $search->setSlice( 0, 1 ); |
|
236 | + $search->setConditions($search->combine('&&', $expr)); |
|
237 | + $search->setSlice(0, 1); |
|
238 | 238 | |
239 | - $result = $manager->searchItems( $search ); |
|
239 | + $result = $manager->searchItems($search); |
|
240 | 240 | |
241 | - if( ( $item = reset( $result ) ) === false ) { |
|
242 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon for code "%1$s" is not available any more', $code ) ); |
|
241 | + if (($item = reset($result)) === false) { |
|
242 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon for code "%1$s" is not available any more', $code)); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | |
246 | - $provider = $manager->getProvider( $item, $code ); |
|
246 | + $provider = $manager->getProvider($item, $code); |
|
247 | 247 | |
248 | - if( $provider->isAvailable( $this->basket ) !== true ) { |
|
249 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Requirements for coupon code "%1$s" aren\'t met', $code ) ); |
|
248 | + if ($provider->isAvailable($this->basket) !== true) { |
|
249 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Requirements for coupon code "%1$s" aren\'t met', $code)); |
|
250 | 250 | } |
251 | 251 | |
252 | - $provider->addCoupon( $this->basket ); |
|
253 | - $this->domainManager->setSession( $this->basket ); |
|
252 | + $provider->addCoupon($this->basket); |
|
253 | + $this->domainManager->setSession($this->basket); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | |
@@ -260,22 +260,22 @@ discard block |
||
260 | 260 | * @param string $code Coupon code entered by the user |
261 | 261 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
262 | 262 | */ |
263 | - public function deleteCoupon( $code ) |
|
263 | + public function deleteCoupon($code) |
|
264 | 264 | { |
265 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
265 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
266 | 266 | |
267 | 267 | $search = $manager->createSearch(); |
268 | - $search->setConditions( $search->compare( '==', 'coupon.code.code', $code ) ); |
|
269 | - $search->setSlice( 0, 1 ); |
|
268 | + $search->setConditions($search->compare('==', 'coupon.code.code', $code)); |
|
269 | + $search->setSlice(0, 1); |
|
270 | 270 | |
271 | - $result = $manager->searchItems( $search ); |
|
271 | + $result = $manager->searchItems($search); |
|
272 | 272 | |
273 | - if( ( $item = reset( $result ) ) === false ) { |
|
274 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon code "%1$s" is invalid', $code ) ); |
|
273 | + if (($item = reset($result)) === false) { |
|
274 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon code "%1$s" is invalid', $code)); |
|
275 | 275 | } |
276 | 276 | |
277 | - $manager->getProvider( $item, $code )->deleteCoupon( $this->basket ); |
|
278 | - $this->domainManager->setSession( $this->basket ); |
|
277 | + $manager->getProvider($item, $code)->deleteCoupon($this->basket); |
|
278 | + $this->domainManager->setSession($this->basket); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | |
@@ -287,31 +287,31 @@ discard block |
||
287 | 287 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the billing or delivery address is not of any required type of |
288 | 288 | * if one of the keys is invalid when using an array with key/value pairs |
289 | 289 | */ |
290 | - public function setAddress( $type, $value ) |
|
290 | + public function setAddress($type, $value) |
|
291 | 291 | { |
292 | - $address = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/address' )->createItem(); |
|
293 | - $address->setType( $type ); |
|
292 | + $address = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/address')->createItem(); |
|
293 | + $address->setType($type); |
|
294 | 294 | |
295 | - if( $value instanceof \Aimeos\MShop\Common\Item\Address\Iface ) |
|
295 | + if ($value instanceof \Aimeos\MShop\Common\Item\Address\Iface) |
|
296 | 296 | { |
297 | - $address->copyFrom( $value ); |
|
298 | - $this->basket->setAddress( $address, $type ); |
|
297 | + $address->copyFrom($value); |
|
298 | + $this->basket->setAddress($address, $type); |
|
299 | 299 | } |
300 | - else if( is_array( $value ) ) |
|
300 | + else if (is_array($value)) |
|
301 | 301 | { |
302 | - $this->setAddressFromArray( $address, $value ); |
|
303 | - $this->basket->setAddress( $address, $type ); |
|
302 | + $this->setAddressFromArray($address, $value); |
|
303 | + $this->basket->setAddress($address, $type); |
|
304 | 304 | } |
305 | - else if( $value === null ) |
|
305 | + else if ($value === null) |
|
306 | 306 | { |
307 | - $this->basket->deleteAddress( $type ); |
|
307 | + $this->basket->deleteAddress($type); |
|
308 | 308 | } |
309 | 309 | else |
310 | 310 | { |
311 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Invalid value for address type "%1$s"', $type ) ); |
|
311 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Invalid value for address type "%1$s"', $type)); |
|
312 | 312 | } |
313 | 313 | |
314 | - $this->domainManager->setSession( $this->basket ); |
|
314 | + $this->domainManager->setSession($this->basket); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | |
@@ -324,43 +324,43 @@ discard block |
||
324 | 324 | * entered by the customer when choosing one of the delivery or payment options |
325 | 325 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
326 | 326 | */ |
327 | - public function setService( $type, $id, array $attributes = array() ) |
|
327 | + public function setService($type, $id, array $attributes = array()) |
|
328 | 328 | { |
329 | 329 | $context = $this->getContext(); |
330 | 330 | |
331 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $context, 'service' ); |
|
332 | - $serviceItem = $this->getDomainItem( 'service', 'service.id', $id, array( 'media', 'price', 'text' ) ); |
|
331 | + $serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service'); |
|
332 | + $serviceItem = $this->getDomainItem('service', 'service.id', $id, array('media', 'price', 'text')); |
|
333 | 333 | |
334 | - $provider = $serviceManager->getProvider( $serviceItem ); |
|
335 | - $result = $provider->checkConfigFE( $attributes ); |
|
336 | - $unknown = array_diff_key( $attributes, $result ); |
|
334 | + $provider = $serviceManager->getProvider($serviceItem); |
|
335 | + $result = $provider->checkConfigFE($attributes); |
|
336 | + $unknown = array_diff_key($attributes, $result); |
|
337 | 337 | |
338 | - if( count( $unknown ) > 0 ) |
|
338 | + if (count($unknown) > 0) |
|
339 | 339 | { |
340 | - $msg = sprintf( 'Unknown attributes "%1$s"', implode( '","', array_keys( $unknown ) ) ); |
|
341 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
340 | + $msg = sprintf('Unknown attributes "%1$s"', implode('","', array_keys($unknown))); |
|
341 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
342 | 342 | } |
343 | 343 | |
344 | - foreach( $result as $key => $value ) |
|
344 | + foreach ($result as $key => $value) |
|
345 | 345 | { |
346 | - if( $value !== null ) { |
|
347 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $value ); |
|
346 | + if ($value !== null) { |
|
347 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($value); |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 | |
351 | - $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/service' ); |
|
351 | + $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/service'); |
|
352 | 352 | $orderServiceItem = $orderBaseServiceManager->createItem(); |
353 | - $orderServiceItem->copyFrom( $serviceItem ); |
|
353 | + $orderServiceItem->copyFrom($serviceItem); |
|
354 | 354 | |
355 | - $price = $provider->calcPrice( $this->basket ); |
|
355 | + $price = $provider->calcPrice($this->basket); |
|
356 | 356 | // remove service rebate of original price |
357 | - $price->setRebate( '0.00' ); |
|
358 | - $orderServiceItem->setPrice( $price ); |
|
357 | + $price->setRebate('0.00'); |
|
358 | + $orderServiceItem->setPrice($price); |
|
359 | 359 | |
360 | - $provider->setConfigFE( $orderServiceItem, $attributes ); |
|
360 | + $provider->setConfigFE($orderServiceItem, $attributes); |
|
361 | 361 | |
362 | - $this->basket->setService( $orderServiceItem, $type ); |
|
363 | - $this->domainManager->setSession( $this->basket ); |
|
362 | + $this->basket->setService($orderServiceItem, $type); |
|
363 | + $this->domainManager->setSession($this->basket); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | |
@@ -372,44 +372,44 @@ discard block |
||
372 | 372 | * @param array $variantAttributeIds List of product variant attribute IDs |
373 | 373 | * @param string $stocktype |
374 | 374 | */ |
375 | - protected function addBundleProducts( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
376 | - \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype ) |
|
375 | + protected function addBundleProducts(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
376 | + \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype) |
|
377 | 377 | { |
378 | 378 | $quantity = $orderBaseProductItem->getQuantity(); |
379 | 379 | $products = $subProductIds = $orderProducts = array(); |
380 | - $orderProductManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product' ); |
|
380 | + $orderProductManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product'); |
|
381 | 381 | |
382 | - foreach( $productItem->getRefItems( 'product', null, 'default' ) as $item ) { |
|
382 | + foreach ($productItem->getRefItems('product', null, 'default') as $item) { |
|
383 | 383 | $subProductIds[] = $item->getId(); |
384 | 384 | } |
385 | 385 | |
386 | - if( count( $subProductIds ) > 0 ) |
|
386 | + if (count($subProductIds) > 0) |
|
387 | 387 | { |
388 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
388 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
389 | 389 | |
390 | - $search = $productManager->createSearch( true ); |
|
390 | + $search = $productManager->createSearch(true); |
|
391 | 391 | $expr = array( |
392 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
392 | + $search->compare('==', 'product.id', $subProductIds), |
|
393 | 393 | $search->getConditions(), |
394 | 394 | ); |
395 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
395 | + $search->setConditions($search->combine('&&', $expr)); |
|
396 | 396 | |
397 | - $products = $productManager->searchItems( $search, array( 'attribute', 'media', 'price', 'text' ) ); |
|
397 | + $products = $productManager->searchItems($search, array('attribute', 'media', 'price', 'text')); |
|
398 | 398 | } |
399 | 399 | |
400 | - foreach( $products as $product ) |
|
400 | + foreach ($products as $product) |
|
401 | 401 | { |
402 | - $prices = $product->getRefItems( 'price', 'default', 'default' ); |
|
402 | + $prices = $product->getRefItems('price', 'default', 'default'); |
|
403 | 403 | |
404 | 404 | $orderProduct = $orderProductManager->createItem(); |
405 | - $orderProduct->copyFrom( $product ); |
|
406 | - $orderProduct->setStockType( $stocktype ); |
|
407 | - $orderProduct->setPrice( $this->calcPrice( $orderProduct, $prices, $quantity ) ); |
|
405 | + $orderProduct->copyFrom($product); |
|
406 | + $orderProduct->setStockType($stocktype); |
|
407 | + $orderProduct->setPrice($this->calcPrice($orderProduct, $prices, $quantity)); |
|
408 | 408 | |
409 | 409 | $orderProducts[] = $orderProduct; |
410 | 410 | } |
411 | 411 | |
412 | - $orderBaseProductItem->setProducts( $orderProducts ); |
|
412 | + $orderBaseProductItem->setProducts($orderProducts); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | |
@@ -423,37 +423,37 @@ discard block |
||
423 | 423 | * @param string $stocktype Stock type for retrieving the stock level |
424 | 424 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there's not enough stock available |
425 | 425 | */ |
426 | - protected function addProductInStock( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
427 | - $productId, $quantity, array $options, $stocktype ) |
|
426 | + protected function addProductInStock(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
427 | + $productId, $quantity, array $options, $stocktype) |
|
428 | 428 | { |
429 | 429 | $stocklevel = null; |
430 | - if( !isset( $options['stock'] ) || $options['stock'] != false ) { |
|
431 | - $stocklevel = $this->getStockLevel( $productId, $stocktype ); |
|
430 | + if (!isset($options['stock']) || $options['stock'] != false) { |
|
431 | + $stocklevel = $this->getStockLevel($productId, $stocktype); |
|
432 | 432 | } |
433 | 433 | |
434 | - if( $stocklevel === null || $stocklevel > 0 ) |
|
434 | + if ($stocklevel === null || $stocklevel > 0) |
|
435 | 435 | { |
436 | - $position = $this->get()->addProduct( $orderBaseProductItem ); |
|
436 | + $position = $this->get()->addProduct($orderBaseProductItem); |
|
437 | 437 | |
438 | 438 | try |
439 | 439 | { |
440 | - $orderBaseProductItem = clone $this->get()->getProduct( $position ); |
|
440 | + $orderBaseProductItem = clone $this->get()->getProduct($position); |
|
441 | 441 | $quantity = $orderBaseProductItem->getQuantity(); |
442 | 442 | |
443 | - if( $stocklevel > 0 && $stocklevel < $quantity ) |
|
443 | + if ($stocklevel > 0 && $stocklevel < $quantity) |
|
444 | 444 | { |
445 | - $this->get()->deleteProduct( $position ); |
|
446 | - $orderBaseProductItem->setQuantity( $stocklevel ); |
|
447 | - $this->get()->addProduct( $orderBaseProductItem, $position ); |
|
445 | + $this->get()->deleteProduct($position); |
|
446 | + $orderBaseProductItem->setQuantity($stocklevel); |
|
447 | + $this->get()->addProduct($orderBaseProductItem, $position); |
|
448 | 448 | } |
449 | 449 | } |
450 | - catch( \Aimeos\MShop\Order\Exception $e ) {} // hide error if product position changed by plugin |
|
450 | + catch (\Aimeos\MShop\Order\Exception $e) {} // hide error if product position changed by plugin |
|
451 | 451 | } |
452 | 452 | |
453 | - if( $stocklevel !== null && $stocklevel < $quantity ) |
|
453 | + if ($stocklevel !== null && $stocklevel < $quantity) |
|
454 | 454 | { |
455 | - $msg = sprintf( 'There are not enough products "%1$s" in stock', $orderBaseProductItem->getName() ); |
|
456 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
455 | + $msg = sprintf('There are not enough products "%1$s" in stock', $orderBaseProductItem->getName()); |
|
456 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
457 | 457 | } |
458 | 458 | } |
459 | 459 | |
@@ -469,36 +469,36 @@ discard block |
||
469 | 469 | * @param array $attributeValues Associative list of attribute IDs as keys and their codes as values |
470 | 470 | * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface |
471 | 471 | */ |
472 | - protected function createOrderProductAttributes( \Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
473 | - array $attributeIds, $type, array $attributeValues = array() ) |
|
472 | + protected function createOrderProductAttributes(\Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
473 | + array $attributeIds, $type, array $attributeValues = array()) |
|
474 | 474 | { |
475 | - if( empty( $attributeIds ) ) { |
|
475 | + if (empty($attributeIds)) { |
|
476 | 476 | return array(); |
477 | 477 | } |
478 | 478 | |
479 | - $attrTypeId = $this->getProductListTypeItem( 'attribute', $type )->getId(); |
|
480 | - $this->checkReferences( $prodid, 'attribute', $attrTypeId, $attributeIds ); |
|
479 | + $attrTypeId = $this->getProductListTypeItem('attribute', $type)->getId(); |
|
480 | + $this->checkReferences($prodid, 'attribute', $attrTypeId, $attributeIds); |
|
481 | 481 | |
482 | 482 | $list = array(); |
483 | 483 | $context = $this->getContext(); |
484 | 484 | |
485 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
486 | - $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product/attribute' ); |
|
485 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
486 | + $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product/attribute'); |
|
487 | 487 | |
488 | - foreach( $this->getAttributes( $attributeIds ) as $id => $attrItem ) |
|
488 | + foreach ($this->getAttributes($attributeIds) as $id => $attrItem) |
|
489 | 489 | { |
490 | - $prices = $attrItem->getRefItems( 'price', 'default', 'default' ); |
|
490 | + $prices = $attrItem->getRefItems('price', 'default', 'default'); |
|
491 | 491 | |
492 | - if( !empty( $prices ) ) { |
|
493 | - $price->addItem( $priceManager->getLowestPrice( $prices, $quantity ) ); |
|
492 | + if (!empty($prices)) { |
|
493 | + $price->addItem($priceManager->getLowestPrice($prices, $quantity)); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | $item = $orderProductAttributeManager->createItem(); |
497 | - $item->copyFrom( $attrItem ); |
|
498 | - $item->setType( $type ); |
|
497 | + $item->copyFrom($attrItem); |
|
498 | + $item->setType($type); |
|
499 | 499 | |
500 | - if( isset( $attributeValues[$id] ) ) { |
|
501 | - $item->setValue( $attributeValues[$id] ); |
|
500 | + if (isset($attributeValues[$id])) { |
|
501 | + $item->setValue($attributeValues[$id]); |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | $list[] = $item; |
@@ -518,26 +518,26 @@ discard block |
||
518 | 518 | * @param array Associative list of options |
519 | 519 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there's not enough stock available |
520 | 520 | */ |
521 | - protected function editProductInStock( \Aimeos\MShop\Order\Item\Base\Product\Iface $product, |
|
522 | - \Aimeos\MShop\Product\Item\Iface $productItem, $quantity, $position, array $options ) |
|
521 | + protected function editProductInStock(\Aimeos\MShop\Order\Item\Base\Product\Iface $product, |
|
522 | + \Aimeos\MShop\Product\Item\Iface $productItem, $quantity, $position, array $options) |
|
523 | 523 | { |
524 | 524 | $stocklevel = null; |
525 | - if( !isset( $options['stock'] ) || $options['stock'] != false ) { |
|
526 | - $stocklevel = $this->getStockLevel( $productItem->getId(), $product->getStockType() ); |
|
525 | + if (!isset($options['stock']) || $options['stock'] != false) { |
|
526 | + $stocklevel = $this->getStockLevel($productItem->getId(), $product->getStockType()); |
|
527 | 527 | } |
528 | 528 | |
529 | - $product->setQuantity( ( $stocklevel !== null && $stocklevel > 0 ? min( $stocklevel, $quantity ) : $quantity ) ); |
|
529 | + $product->setQuantity(($stocklevel !== null && $stocklevel > 0 ? min($stocklevel, $quantity) : $quantity)); |
|
530 | 530 | |
531 | - $this->get()->deleteProduct( $position ); |
|
531 | + $this->get()->deleteProduct($position); |
|
532 | 532 | |
533 | - if( $stocklevel === null || $stocklevel > 0 ) { |
|
534 | - $this->get()->addProduct( $product, $position ); |
|
533 | + if ($stocklevel === null || $stocklevel > 0) { |
|
534 | + $this->get()->addProduct($product, $position); |
|
535 | 535 | } |
536 | 536 | |
537 | - if( $stocklevel !== null && $stocklevel < $quantity ) |
|
537 | + if ($stocklevel !== null && $stocklevel < $quantity) |
|
538 | 538 | { |
539 | - $msg = sprintf( 'There are not enough products "%1$s" in stock', $productItem->getName() ); |
|
540 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
539 | + $msg = sprintf('There are not enough products "%1$s" in stock', $productItem->getName()); |
|
540 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
541 | 541 | } |
542 | 542 | } |
543 | 543 | |
@@ -552,23 +552,23 @@ discard block |
||
552 | 552 | * @return \Aimeos\MShop\Common\Item\Iface Domain item object |
553 | 553 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
554 | 554 | */ |
555 | - protected function getDomainItem( $domain, $key, $value, array $ref ) |
|
555 | + protected function getDomainItem($domain, $key, $value, array $ref) |
|
556 | 556 | { |
557 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $domain ); |
|
557 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $domain); |
|
558 | 558 | |
559 | - $search = $manager->createSearch( true ); |
|
559 | + $search = $manager->createSearch(true); |
|
560 | 560 | $expr = array( |
561 | - $search->compare( '==', $key, $value ), |
|
561 | + $search->compare('==', $key, $value), |
|
562 | 562 | $search->getConditions(), |
563 | 563 | ); |
564 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
564 | + $search->setConditions($search->combine('&&', $expr)); |
|
565 | 565 | |
566 | - $result = $manager->searchItems( $search, $ref ); |
|
566 | + $result = $manager->searchItems($search, $ref); |
|
567 | 567 | |
568 | - if( ( $item = reset( $result ) ) === false ) |
|
568 | + if (($item = reset($result)) === false) |
|
569 | 569 | { |
570 | - $msg = sprintf( 'No item for "%1$s" (%2$s) found', $value, $key ); |
|
571 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
570 | + $msg = sprintf('No item for "%1$s" (%2$s) found', $value, $key); |
|
571 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | return $item; |
@@ -586,50 +586,50 @@ discard block |
||
586 | 586 | * @return \Aimeos\MShop\Order\Item\Base\Product\Attribute\Iface[] List of order product attributes |
587 | 587 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If no product variant is found |
588 | 588 | */ |
589 | - protected function getVariantDetails( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
590 | - \Aimeos\MShop\Product\Item\Iface &$productItem, array &$prices, array $variantAttributeIds, array $options ) |
|
589 | + protected function getVariantDetails(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
590 | + \Aimeos\MShop\Product\Item\Iface & $productItem, array &$prices, array $variantAttributeIds, array $options) |
|
591 | 591 | { |
592 | 592 | $attr = array(); |
593 | - $productItems = $this->getProductVariants( $productItem, $variantAttributeIds ); |
|
593 | + $productItems = $this->getProductVariants($productItem, $variantAttributeIds); |
|
594 | 594 | |
595 | - if( count( $productItems ) > 1 ) |
|
595 | + if (count($productItems) > 1) |
|
596 | 596 | { |
597 | - $msg = sprintf( 'No unique article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
|
598 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
597 | + $msg = sprintf('No unique article found for selected attributes and product ID "%1$s"', $productItem->getId()); |
|
598 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
599 | 599 | } |
600 | - else if( ( $result = reset( $productItems ) ) !== false ) // count == 1 |
|
600 | + else if (($result = reset($productItems)) !== false) // count == 1 |
|
601 | 601 | { |
602 | 602 | $productItem = $result; |
603 | - $orderBaseProductItem->setProductCode( $productItem->getCode() ); |
|
603 | + $orderBaseProductItem->setProductCode($productItem->getCode()); |
|
604 | 604 | |
605 | - $subprices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
605 | + $subprices = $productItem->getRefItems('price', 'default', 'default'); |
|
606 | 606 | |
607 | - if( !empty( $subprices ) ) { |
|
607 | + if (!empty($subprices)) { |
|
608 | 608 | $prices = $subprices; |
609 | 609 | } |
610 | 610 | |
611 | - $submedia = $productItem->getRefItems( 'media', 'default', 'default' ); |
|
611 | + $submedia = $productItem->getRefItems('media', 'default', 'default'); |
|
612 | 612 | |
613 | - if( ( $mediaItem = reset( $submedia ) ) !== false ) { |
|
614 | - $orderBaseProductItem->setMediaUrl( $mediaItem->getPreview() ); |
|
613 | + if (($mediaItem = reset($submedia)) !== false) { |
|
614 | + $orderBaseProductItem->setMediaUrl($mediaItem->getPreview()); |
|
615 | 615 | } |
616 | 616 | |
617 | - $orderProductAttrManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product/attribute' ); |
|
618 | - $variantAttributes = $productItem->getRefItems( 'attribute', null, 'variant' ); |
|
617 | + $orderProductAttrManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product/attribute'); |
|
618 | + $variantAttributes = $productItem->getRefItems('attribute', null, 'variant'); |
|
619 | 619 | |
620 | - foreach( $this->getAttributes( array_keys( $variantAttributes ), array( 'text' ) ) as $attrItem ) |
|
620 | + foreach ($this->getAttributes(array_keys($variantAttributes), array('text')) as $attrItem) |
|
621 | 621 | { |
622 | 622 | $orderAttributeItem = $orderProductAttrManager->createItem(); |
623 | - $orderAttributeItem->copyFrom( $attrItem ); |
|
624 | - $orderAttributeItem->setType( 'variant' ); |
|
623 | + $orderAttributeItem->copyFrom($attrItem); |
|
624 | + $orderAttributeItem->setType('variant'); |
|
625 | 625 | |
626 | 626 | $attr[] = $orderAttributeItem; |
627 | 627 | } |
628 | 628 | } |
629 | - else if( !isset( $options['variant'] ) || $options['variant'] != false ) // count == 0 |
|
629 | + else if (!isset($options['variant']) || $options['variant'] != false) // count == 0 |
|
630 | 630 | { |
631 | - $msg = sprintf( 'No article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
|
632 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
631 | + $msg = sprintf('No article found for selected attributes and product ID "%1$s"', $productItem->getId()); |
|
632 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | return $attr; |
@@ -644,18 +644,18 @@ discard block |
||
644 | 644 | * an address item. |
645 | 645 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
646 | 646 | */ |
647 | - protected function setAddressFromArray( \Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map ) |
|
647 | + protected function setAddressFromArray(\Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map) |
|
648 | 648 | { |
649 | - foreach( $map as $key => $value ) { |
|
650 | - $map[$key] = strip_tags( $value ); // prevent XSS |
|
649 | + foreach ($map as $key => $value) { |
|
650 | + $map[$key] = strip_tags($value); // prevent XSS |
|
651 | 651 | } |
652 | 652 | |
653 | - $errors = $address->fromArray( $map ); |
|
653 | + $errors = $address->fromArray($map); |
|
654 | 654 | |
655 | - if( count( $errors ) > 0 ) |
|
655 | + if (count($errors) > 0) |
|
656 | 656 | { |
657 | - $msg = sprintf( 'Invalid address properties, please check your input' ); |
|
658 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg, 0, null, $errors ); |
|
657 | + $msg = sprintf('Invalid address properties, please check your input'); |
|
658 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg, 0, null, $errors); |
|
659 | 659 | } |
660 | 660 | } |
661 | 661 | } |
@@ -16,130 +16,130 @@ discard block |
||
16 | 16 | |
17 | 17 | protected function setUp() |
18 | 18 | { |
19 | - $this->object = new \Aimeos\Controller\Frontend\Service\Standard( \TestHelperFrontend::getContext() ); |
|
19 | + $this->object = new \Aimeos\Controller\Frontend\Service\Standard(\TestHelperFrontend::getContext()); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
23 | 23 | public static function setUpBeforeClass() |
24 | 24 | { |
25 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
26 | - $orderBaseMgr = $orderManager->getSubManager( 'base' ); |
|
25 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
26 | + $orderBaseMgr = $orderManager->getSubManager('base'); |
|
27 | 27 | self::$basket = $orderBaseMgr->createItem(); |
28 | 28 | } |
29 | 29 | |
30 | 30 | |
31 | 31 | protected function tearDown() |
32 | 32 | { |
33 | - unset( $this->object ); |
|
33 | + unset($this->object); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | |
37 | 37 | public function testGetServices() |
38 | 38 | { |
39 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
40 | - $basket = $orderManager->getSubManager( 'base' )->createItem(); |
|
39 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
40 | + $basket = $orderManager->getSubManager('base')->createItem(); |
|
41 | 41 | |
42 | - $services = $this->object->getServices( 'delivery', $basket ); |
|
43 | - $this->assertGreaterThan( 0, count( $services ) ); |
|
42 | + $services = $this->object->getServices('delivery', $basket); |
|
43 | + $this->assertGreaterThan(0, count($services)); |
|
44 | 44 | |
45 | - foreach( $services as $service ) { |
|
46 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Service\\Item\\Iface', $service ); |
|
45 | + foreach ($services as $service) { |
|
46 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Service\\Item\\Iface', $service); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
50 | 50 | |
51 | 51 | public function testGetServicesCache() |
52 | 52 | { |
53 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
54 | - $basket = $orderManager->getSubManager( 'base' )->createItem(); |
|
53 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
54 | + $basket = $orderManager->getSubManager('base')->createItem(); |
|
55 | 55 | |
56 | - $this->object->getServices( 'delivery', $basket ); |
|
57 | - $services = $this->object->getServices( 'delivery', $basket ); |
|
56 | + $this->object->getServices('delivery', $basket); |
|
57 | + $services = $this->object->getServices('delivery', $basket); |
|
58 | 58 | |
59 | - $this->assertGreaterThan( 0, count( $services ) ); |
|
59 | + $this->assertGreaterThan(0, count($services)); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
63 | 63 | public function testGetServiceAttributes() |
64 | 64 | { |
65 | 65 | $service = $this->getServiceItem(); |
66 | - $attributes = $this->object->getServiceAttributes( 'delivery', $service->getId(), self::$basket ); |
|
66 | + $attributes = $this->object->getServiceAttributes('delivery', $service->getId(), self::$basket); |
|
67 | 67 | |
68 | - $this->assertEquals( 0, count( $attributes ) ); |
|
68 | + $this->assertEquals(0, count($attributes)); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
72 | 72 | public function testGetServiceAttributesCache() |
73 | 73 | { |
74 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
75 | - $basket = $orderManager->getSubManager( 'base' )->createItem(); |
|
74 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
75 | + $basket = $orderManager->getSubManager('base')->createItem(); |
|
76 | 76 | |
77 | - $services = $this->object->getServices( 'delivery', $basket ); |
|
77 | + $services = $this->object->getServices('delivery', $basket); |
|
78 | 78 | |
79 | - if( ( $service = reset( $services ) ) === false ) { |
|
80 | - throw new \RuntimeException( 'No service item found' ); |
|
79 | + if (($service = reset($services)) === false) { |
|
80 | + throw new \RuntimeException('No service item found'); |
|
81 | 81 | } |
82 | 82 | |
83 | - $attributes = $this->object->getServiceAttributes( 'delivery', $service->getId(), self::$basket ); |
|
83 | + $attributes = $this->object->getServiceAttributes('delivery', $service->getId(), self::$basket); |
|
84 | 84 | |
85 | - $this->assertEquals( 0, count( $attributes ) ); |
|
85 | + $this->assertEquals(0, count($attributes)); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | |
89 | 89 | public function testGetServiceAttributesNoItems() |
90 | 90 | { |
91 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Service\\Exception' ); |
|
92 | - $this->object->getServiceAttributes( 'invalid', -1, self::$basket ); |
|
91 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Service\\Exception'); |
|
92 | + $this->object->getServiceAttributes('invalid', -1, self::$basket); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
96 | 96 | public function testGetServicePrice() |
97 | 97 | { |
98 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
99 | - $basket = $orderManager->getSubManager( 'base' )->createItem(); |
|
98 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
99 | + $basket = $orderManager->getSubManager('base')->createItem(); |
|
100 | 100 | |
101 | 101 | $service = $this->getServiceItem(); |
102 | - $price = $this->object->getServicePrice( 'delivery', $service->getId(), $basket ); |
|
102 | + $price = $this->object->getServicePrice('delivery', $service->getId(), $basket); |
|
103 | 103 | |
104 | - $this->assertEquals( '12.95', $price->getValue() ); |
|
105 | - $this->assertEquals( '1.99', $price->getCosts() ); |
|
104 | + $this->assertEquals('12.95', $price->getValue()); |
|
105 | + $this->assertEquals('1.99', $price->getCosts()); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
109 | 109 | public function testGetServicePriceCache() |
110 | 110 | { |
111 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
112 | - $basket = $orderManager->getSubManager( 'base' )->createItem(); |
|
111 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
112 | + $basket = $orderManager->getSubManager('base')->createItem(); |
|
113 | 113 | |
114 | - $services = $this->object->getServices( 'delivery', $basket ); |
|
114 | + $services = $this->object->getServices('delivery', $basket); |
|
115 | 115 | |
116 | - if( ( $service = reset( $services ) ) === false ) { |
|
117 | - throw new \RuntimeException( 'No service item found' ); |
|
116 | + if (($service = reset($services)) === false) { |
|
117 | + throw new \RuntimeException('No service item found'); |
|
118 | 118 | } |
119 | 119 | |
120 | - $price = $this->object->getServicePrice( 'delivery', $service->getId(), $basket ); |
|
120 | + $price = $this->object->getServicePrice('delivery', $service->getId(), $basket); |
|
121 | 121 | |
122 | - $this->assertEquals( '12.95', $price->getValue() ); |
|
123 | - $this->assertEquals( '1.99', $price->getCosts() ); |
|
122 | + $this->assertEquals('12.95', $price->getValue()); |
|
123 | + $this->assertEquals('1.99', $price->getCosts()); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | |
127 | 127 | public function testGetServicePriceNoItems() |
128 | 128 | { |
129 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
130 | - $basket = $orderManager->getSubManager( 'base' )->createItem(); |
|
129 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
130 | + $basket = $orderManager->getSubManager('base')->createItem(); |
|
131 | 131 | |
132 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Service\\Exception' ); |
|
133 | - $this->object->getServicePrice( 'invalid', -1, $basket ); |
|
132 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Service\\Exception'); |
|
133 | + $this->object->getServicePrice('invalid', -1, $basket); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | |
137 | 137 | public function testCheckServiceAttributes() |
138 | 138 | { |
139 | 139 | $service = $this->getServiceItem(); |
140 | - $attributes = $this->object->checkServiceAttributes( 'delivery', $service->getId(), array() ); |
|
140 | + $attributes = $this->object->checkServiceAttributes('delivery', $service->getId(), array()); |
|
141 | 141 | |
142 | - $this->assertEquals( array(), $attributes ); |
|
142 | + $this->assertEquals(array(), $attributes); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | |
@@ -148,21 +148,21 @@ discard block |
||
148 | 148 | */ |
149 | 149 | protected function getServiceItem() |
150 | 150 | { |
151 | - $serviceManager = \Aimeos\MShop\Service\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
151 | + $serviceManager = \Aimeos\MShop\Service\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
152 | 152 | |
153 | - $search = $serviceManager->createSearch( true ); |
|
153 | + $search = $serviceManager->createSearch(true); |
|
154 | 154 | $expr = array( |
155 | 155 | $search->getConditions(), |
156 | - $search->compare( '==', 'service.provider', 'Standard' ), |
|
157 | - $search->compare( '==', 'service.type.domain', 'service' ), |
|
158 | - $search->compare( '==', 'service.type.code', 'delivery' ), |
|
156 | + $search->compare('==', 'service.provider', 'Standard'), |
|
157 | + $search->compare('==', 'service.type.domain', 'service'), |
|
158 | + $search->compare('==', 'service.type.code', 'delivery'), |
|
159 | 159 | ); |
160 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
160 | + $search->setConditions($search->combine('&&', $expr)); |
|
161 | 161 | |
162 | - $services = $serviceManager->searchItems( $search ); |
|
162 | + $services = $serviceManager->searchItems($search); |
|
163 | 163 | |
164 | - if( ( $service = reset( $services ) ) === false ) { |
|
165 | - throw new \RuntimeException( 'No service item found' ); |
|
164 | + if (($service = reset($services)) === false) { |
|
165 | + throw new \RuntimeException('No service item found'); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | return $service; |