@@ -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, json_encode( $prodId ) ); |
|
101 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
100 | + $msg = sprintf('Invalid "%1$s" references for product with ID %2$s', $domain, json_encode($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; |
@@ -295,36 +295,36 @@ discard block |
||
295 | 295 | * @param array $attributeValues Associative list of attribute IDs as keys and their codes as values |
296 | 296 | * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface |
297 | 297 | */ |
298 | - protected function createOrderProductAttributes( \Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
299 | - array $attributeIds, $type, array $attributeValues = array() ) |
|
298 | + protected function createOrderProductAttributes(\Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
299 | + array $attributeIds, $type, array $attributeValues = array()) |
|
300 | 300 | { |
301 | - if( empty( $attributeIds ) ) { |
|
301 | + if (empty($attributeIds)) { |
|
302 | 302 | return array(); |
303 | 303 | } |
304 | 304 | |
305 | - $attrTypeId = $this->getProductListTypeItem( 'attribute', $type )->getId(); |
|
306 | - $this->checkReferences( $prodid, 'attribute', $attrTypeId, $attributeIds ); |
|
305 | + $attrTypeId = $this->getProductListTypeItem('attribute', $type)->getId(); |
|
306 | + $this->checkReferences($prodid, 'attribute', $attrTypeId, $attributeIds); |
|
307 | 307 | |
308 | 308 | $list = array(); |
309 | 309 | $context = $this->getContext(); |
310 | 310 | |
311 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
312 | - $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product/attribute' ); |
|
311 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
312 | + $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product/attribute'); |
|
313 | 313 | |
314 | - foreach( $this->getAttributes( $attributeIds ) as $id => $attrItem ) |
|
314 | + foreach ($this->getAttributes($attributeIds) as $id => $attrItem) |
|
315 | 315 | { |
316 | - $prices = $attrItem->getRefItems( 'price', 'default', 'default' ); |
|
316 | + $prices = $attrItem->getRefItems('price', 'default', 'default'); |
|
317 | 317 | |
318 | - if( !empty( $prices ) ) { |
|
319 | - $price->addItem( $priceManager->getLowestPrice( $prices, $quantity ) ); |
|
318 | + if (!empty($prices)) { |
|
319 | + $price->addItem($priceManager->getLowestPrice($prices, $quantity)); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | $item = $orderProductAttributeManager->createItem(); |
323 | - $item->copyFrom( $attrItem ); |
|
324 | - $item->setType( $type ); |
|
323 | + $item->copyFrom($attrItem); |
|
324 | + $item->setType($type); |
|
325 | 325 | |
326 | - if( isset( $attributeValues[$id] ) ) { |
|
327 | - $item->setValue( $attributeValues[$id] ); |
|
326 | + if (isset($attributeValues[$id])) { |
|
327 | + $item->setValue($attributeValues[$id]); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | $list[] = $item; |
@@ -342,31 +342,31 @@ discard block |
||
342 | 342 | * @return array List of items implementing \Aimeos\MShop\Attribute\Item\Iface |
343 | 343 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the actual attribute number doesn't match the expected one |
344 | 344 | */ |
345 | - protected function getAttributes( array $attributeIds, array $domains = array( 'price', 'text' ) ) |
|
345 | + protected function getAttributes(array $attributeIds, array $domains = array('price', 'text')) |
|
346 | 346 | { |
347 | - if( empty( $attributeIds ) ) { |
|
347 | + if (empty($attributeIds)) { |
|
348 | 348 | return array(); |
349 | 349 | } |
350 | 350 | |
351 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
351 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
352 | 352 | |
353 | - $search = $attributeManager->createSearch( true ); |
|
353 | + $search = $attributeManager->createSearch(true); |
|
354 | 354 | $expr = array( |
355 | - $search->compare( '==', 'attribute.id', $attributeIds ), |
|
355 | + $search->compare('==', 'attribute.id', $attributeIds), |
|
356 | 356 | $search->getConditions(), |
357 | 357 | ); |
358 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
359 | - $search->setSlice( 0, 0x7fffffff ); |
|
358 | + $search->setConditions($search->combine('&&', $expr)); |
|
359 | + $search->setSlice(0, 0x7fffffff); |
|
360 | 360 | |
361 | - $attrItems = $attributeManager->searchItems( $search, $domains ); |
|
361 | + $attrItems = $attributeManager->searchItems($search, $domains); |
|
362 | 362 | |
363 | - if( count( $attrItems ) !== count( $attributeIds ) ) |
|
363 | + if (count($attrItems) !== count($attributeIds)) |
|
364 | 364 | { |
365 | - $expected = implode( ',', $attributeIds ); |
|
366 | - $actual = implode( ',', array_keys( $attrItems ) ); |
|
367 | - $msg = sprintf( 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected ); |
|
365 | + $expected = implode(',', $attributeIds); |
|
366 | + $actual = implode(',', array_keys($attrItems)); |
|
367 | + $msg = sprintf('Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected); |
|
368 | 368 | |
369 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
369 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | return $attrItems; |
@@ -379,31 +379,31 @@ discard block |
||
379 | 379 | * @param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Item[] $orderAttributes List of order product attribute items |
380 | 380 | * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as key and attribute items as values |
381 | 381 | */ |
382 | - protected function getAttributeItems( array $orderAttributes ) |
|
382 | + protected function getAttributeItems(array $orderAttributes) |
|
383 | 383 | { |
384 | - if( empty( $orderAttributes ) ) { |
|
384 | + if (empty($orderAttributes)) { |
|
385 | 385 | return array(); |
386 | 386 | } |
387 | 387 | |
388 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
389 | - $search = $attributeManager->createSearch( true ); |
|
388 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
389 | + $search = $attributeManager->createSearch(true); |
|
390 | 390 | $expr = array(); |
391 | 391 | |
392 | - foreach( $orderAttributes as $item ) |
|
392 | + foreach ($orderAttributes as $item) |
|
393 | 393 | { |
394 | 394 | $tmp = array( |
395 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
396 | - $search->compare( '==', 'attribute.code', $item->getValue() ), |
|
397 | - $search->compare( '==', 'attribute.type.domain', 'product' ), |
|
398 | - $search->compare( '==', 'attribute.type.code', $item->getCode() ), |
|
399 | - $search->compare( '>', 'attribute.type.status', 0 ), |
|
395 | + $search->compare('==', 'attribute.domain', 'product'), |
|
396 | + $search->compare('==', 'attribute.code', $item->getValue()), |
|
397 | + $search->compare('==', 'attribute.type.domain', 'product'), |
|
398 | + $search->compare('==', 'attribute.type.code', $item->getCode()), |
|
399 | + $search->compare('>', 'attribute.type.status', 0), |
|
400 | 400 | $search->getConditions(), |
401 | 401 | ); |
402 | - $expr[] = $search->combine( '&&', $tmp ); |
|
402 | + $expr[] = $search->combine('&&', $tmp); |
|
403 | 403 | } |
404 | 404 | |
405 | - $search->setConditions( $search->combine( '||', $expr ) ); |
|
406 | - return $attributeManager->searchItems( $search, array( 'price' ) ); |
|
405 | + $search->setConditions($search->combine('||', $expr)); |
|
406 | + return $attributeManager->searchItems($search, array('price')); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | |
@@ -417,23 +417,23 @@ discard block |
||
417 | 417 | * @return \Aimeos\MShop\Common\Item\Iface Domain item object |
418 | 418 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
419 | 419 | */ |
420 | - protected function getDomainItem( $domain, $key, $value, array $ref ) |
|
420 | + protected function getDomainItem($domain, $key, $value, array $ref) |
|
421 | 421 | { |
422 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $domain ); |
|
422 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $domain); |
|
423 | 423 | |
424 | - $search = $manager->createSearch( true ); |
|
424 | + $search = $manager->createSearch(true); |
|
425 | 425 | $expr = array( |
426 | - $search->compare( '==', $key, $value ), |
|
426 | + $search->compare('==', $key, $value), |
|
427 | 427 | $search->getConditions(), |
428 | 428 | ); |
429 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
429 | + $search->setConditions($search->combine('&&', $expr)); |
|
430 | 430 | |
431 | - $result = $manager->searchItems( $search, $ref ); |
|
431 | + $result = $manager->searchItems($search, $ref); |
|
432 | 432 | |
433 | - if( ( $item = reset( $result ) ) === false ) |
|
433 | + if (($item = reset($result)) === false) |
|
434 | 434 | { |
435 | - $msg = sprintf( 'No item for "%1$s" (%2$s) found', $value, $key ); |
|
436 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
435 | + $msg = sprintf('No item for "%1$s" (%2$s) found', $value, $key); |
|
436 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | return $item; |
@@ -447,26 +447,26 @@ discard block |
||
447 | 447 | * @param string $code Code of the list type |
448 | 448 | * @return \Aimeos\MShop\Common\Item\Type\Iface List type item |
449 | 449 | */ |
450 | - protected function getProductListTypeItem( $domain, $code ) |
|
450 | + protected function getProductListTypeItem($domain, $code) |
|
451 | 451 | { |
452 | - if( !isset( $this->listTypeAttributes[$domain][$code] ) ) |
|
452 | + if (!isset($this->listTypeAttributes[$domain][$code])) |
|
453 | 453 | { |
454 | - $listTypeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists/type' ); |
|
454 | + $listTypeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists/type'); |
|
455 | 455 | |
456 | - $listTypeSearch = $listTypeManager->createSearch( true ); |
|
456 | + $listTypeSearch = $listTypeManager->createSearch(true); |
|
457 | 457 | $expr = array( |
458 | - $listTypeSearch->compare( '==', 'product.lists.type.domain', $domain ), |
|
459 | - $listTypeSearch->compare( '==', 'product.lists.type.code', $code ), |
|
458 | + $listTypeSearch->compare('==', 'product.lists.type.domain', $domain), |
|
459 | + $listTypeSearch->compare('==', 'product.lists.type.code', $code), |
|
460 | 460 | $listTypeSearch->getConditions(), |
461 | 461 | ); |
462 | - $listTypeSearch->setConditions( $listTypeSearch->combine( '&&', $expr ) ); |
|
462 | + $listTypeSearch->setConditions($listTypeSearch->combine('&&', $expr)); |
|
463 | 463 | |
464 | - $listTypeItems = $listTypeManager->searchItems( $listTypeSearch ); |
|
464 | + $listTypeItems = $listTypeManager->searchItems($listTypeSearch); |
|
465 | 465 | |
466 | - if( ( $listTypeItem = reset( $listTypeItems ) ) === false ) |
|
466 | + if (($listTypeItem = reset($listTypeItems)) === false) |
|
467 | 467 | { |
468 | - $msg = sprintf( 'List type for domain "%1$s" and code "%2$s" not found', $domain, $code ); |
|
469 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
468 | + $msg = sprintf('List type for domain "%1$s" and code "%2$s" not found', $domain, $code); |
|
469 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | $this->listTypeAttributes[$domain][$code] = $listTypeItem; |
@@ -484,43 +484,43 @@ discard block |
||
484 | 484 | * @param array $domains Names of the domain items that should be fetched too |
485 | 485 | * @return array List of products matching the given attributes |
486 | 486 | */ |
487 | - protected function getProductVariants( \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
488 | - array $domains = array( 'attribute', 'media', 'price', 'text' ) ) |
|
487 | + protected function getProductVariants(\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
488 | + array $domains = array('attribute', 'media', 'price', 'text')) |
|
489 | 489 | { |
490 | 490 | $subProductIds = array(); |
491 | - foreach( $productItem->getRefItems( 'product', 'default', 'default' ) as $item ) { |
|
491 | + foreach ($productItem->getRefItems('product', 'default', 'default') as $item) { |
|
492 | 492 | $subProductIds[] = $item->getId(); |
493 | 493 | } |
494 | 494 | |
495 | - if( count( $subProductIds ) === 0 ) { |
|
495 | + if (count($subProductIds) === 0) { |
|
496 | 496 | return array(); |
497 | 497 | } |
498 | 498 | |
499 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
500 | - $search = $productManager->createSearch( true ); |
|
499 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
500 | + $search = $productManager->createSearch(true); |
|
501 | 501 | |
502 | 502 | $expr = array( |
503 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
503 | + $search->compare('==', 'product.id', $subProductIds), |
|
504 | 504 | $search->getConditions(), |
505 | 505 | ); |
506 | 506 | |
507 | - if( count( $variantAttributeIds ) > 0 ) |
|
507 | + if (count($variantAttributeIds) > 0) |
|
508 | 508 | { |
509 | - foreach( $variantAttributeIds as $key => $id ) { |
|
509 | + foreach ($variantAttributeIds as $key => $id) { |
|
510 | 510 | $variantAttributeIds[$key] = (string) $id; |
511 | 511 | } |
512 | 512 | |
513 | - $listTypeItem = $this->getProductListTypeItem( 'attribute', 'variant' ); |
|
513 | + $listTypeItem = $this->getProductListTypeItem('attribute', 'variant'); |
|
514 | 514 | |
515 | - $param = array( 'attribute', $listTypeItem->getId(), $variantAttributeIds ); |
|
516 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
515 | + $param = array('attribute', $listTypeItem->getId(), $variantAttributeIds); |
|
516 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
517 | 517 | |
518 | - $expr[] = $search->compare( '==', $cmpfunc, count( $variantAttributeIds ) ); |
|
518 | + $expr[] = $search->compare('==', $cmpfunc, count($variantAttributeIds)); |
|
519 | 519 | } |
520 | 520 | |
521 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
521 | + $search->setConditions($search->combine('&&', $expr)); |
|
522 | 522 | |
523 | - return $productManager->searchItems( $search, $domains ); |
|
523 | + return $productManager->searchItems($search, $domains); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | |
@@ -532,9 +532,9 @@ discard block |
||
532 | 532 | * @param mixed $default Default value if no value is available for the given name |
533 | 533 | * @return mixed Value from the array or default value |
534 | 534 | */ |
535 | - protected function getValue( array $values, $name, $default = null ) |
|
535 | + protected function getValue(array $values, $name, $default = null) |
|
536 | 536 | { |
537 | - if( isset( $values[$name] ) ) { |
|
537 | + if (isset($values[$name])) { |
|
538 | 538 | return $values[$name]; |
539 | 539 | } |
540 | 540 |