@@ -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 |
@@ -4,7 +4,7 @@ |
||
4 | 4 | 'frontend' => array( |
5 | 5 | 'basket' => array( |
6 | 6 | 'decorators' => array( |
7 | - 'local' => array( 'Category', 'Bundle', 'Select' ), |
|
7 | + 'local' => array('Category', 'Bundle', 'Select'), |
|
8 | 8 | ), |
9 | 9 | ), |
10 | 10 | ), |
@@ -17,63 +17,63 @@ discard block |
||
17 | 17 | |
18 | 18 | protected function setUp() |
19 | 19 | { |
20 | - $this->object = new \Aimeos\Controller\Frontend\Catalog\Standard( \TestHelperFrontend::getContext() ); |
|
20 | + $this->object = new \Aimeos\Controller\Frontend\Catalog\Standard(\TestHelperFrontend::getContext()); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
24 | 24 | protected function tearDown() |
25 | 25 | { |
26 | - unset( $this->object ); |
|
26 | + unset($this->object); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | |
30 | 30 | public function testCreateManager() |
31 | 31 | { |
32 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Manager\\Iface', $this->object->createManager( 'product' ) ); |
|
32 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Manager\\Iface', $this->object->createManager('product')); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
36 | 36 | public function testCreateCatalogFilter() |
37 | 37 | { |
38 | - $filter = $this->object->createCatalogFilter( true ); |
|
38 | + $filter = $this->object->createCatalogFilter(true); |
|
39 | 39 | |
40 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
41 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Expression\\Compare\\Iface', $filter->getConditions() ); |
|
42 | - $this->assertEquals( 'catalog.status', $filter->getConditions()->getName() ); |
|
40 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
41 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Expression\\Compare\\Iface', $filter->getConditions()); |
|
42 | + $this->assertEquals('catalog.status', $filter->getConditions()->getName()); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
46 | 46 | public function testGetCatalogPath() |
47 | 47 | { |
48 | - $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
49 | - $item = $manager->getTree( null, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST ); |
|
48 | + $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
49 | + $item = $manager->getTree(null, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST); |
|
50 | 50 | |
51 | 51 | $list = array(); |
52 | - foreach( $this->object->getCatalogPath( $item->getChild( 0 )->getId(), array( 'text' ) ) as $item ) { |
|
52 | + foreach ($this->object->getCatalogPath($item->getChild(0)->getId(), array('text')) as $item) { |
|
53 | 53 | $list[$item->getCode()] = $item; |
54 | 54 | } |
55 | 55 | |
56 | - $this->assertEquals( 2, count( $list ) ); |
|
57 | - $this->assertArrayHasKey( 'root', $list ); |
|
58 | - $this->assertArrayHasKey( 'categories', $list ); |
|
56 | + $this->assertEquals(2, count($list)); |
|
57 | + $this->assertArrayHasKey('root', $list); |
|
58 | + $this->assertArrayHasKey('categories', $list); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
62 | 62 | public function testGetCatalogTree() |
63 | 63 | { |
64 | - $item = $this->object->getCatalogTree( null, array( 'text' ), \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ); |
|
64 | + $item = $this->object->getCatalogTree(null, array('text'), \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE); |
|
65 | 65 | |
66 | - $this->assertEquals( 'Root', $item->getName() ); |
|
67 | - $this->assertEquals( 0, count( $item->getChildren() ) ); |
|
66 | + $this->assertEquals('Root', $item->getName()); |
|
67 | + $this->assertEquals(0, count($item->getChildren())); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
71 | 71 | public function testAggregateIndex() |
72 | 72 | { |
73 | 73 | $filter = $this->object->createIndexFilter(); |
74 | - $list = $this->object->aggregateIndex( $filter, 'index.attribute.id' ); |
|
74 | + $list = $this->object->aggregateIndex($filter, 'index.attribute.id'); |
|
75 | 75 | |
76 | - $this->assertGreaterThan( 0, count( $list ) ); |
|
76 | + $this->assertGreaterThan(0, count($list)); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | |
@@ -81,279 +81,279 @@ discard block |
||
81 | 81 | { |
82 | 82 | $filter = $this->object->createIndexFilter(); |
83 | 83 | |
84 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
85 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
86 | - $this->assertEquals( 0, $filter->getSliceStart() ); |
|
87 | - $this->assertEquals( 100, $filter->getSliceSize() ); |
|
84 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
85 | + $this->assertEquals(array(), $filter->getSortations()); |
|
86 | + $this->assertEquals(0, $filter->getSliceStart()); |
|
87 | + $this->assertEquals(100, $filter->getSliceSize()); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | |
91 | 91 | public function testCreateIndexFilterCategory() |
92 | 92 | { |
93 | - $filter = $this->object->createIndexFilterCategory( 0 ); |
|
93 | + $filter = $this->object->createIndexFilterCategory(0); |
|
94 | 94 | |
95 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
95 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
96 | 96 | |
97 | 97 | $list = $filter->getConditions()->getExpressions(); |
98 | 98 | |
99 | 99 | |
100 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
101 | - throw new \RuntimeException( 'Wrong expression' ); |
|
100 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
101 | + throw new \RuntimeException('Wrong expression'); |
|
102 | 102 | } |
103 | - $this->assertEquals( 'index.catalog.id', $list[0]->getName() ); |
|
104 | - $this->assertEquals( array( 0 ), $list[0]->getValue() ); |
|
103 | + $this->assertEquals('index.catalog.id', $list[0]->getName()); |
|
104 | + $this->assertEquals(array(0), $list[0]->getValue()); |
|
105 | 105 | |
106 | 106 | |
107 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
108 | - $this->assertEquals( 0, $filter->getSliceStart() ); |
|
109 | - $this->assertEquals( 100, $filter->getSliceSize() ); |
|
107 | + $this->assertEquals(array(), $filter->getSortations()); |
|
108 | + $this->assertEquals(0, $filter->getSliceStart()); |
|
109 | + $this->assertEquals(100, $filter->getSliceSize()); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
113 | 113 | public function testCreateIndexFilterCategoryPosition() |
114 | 114 | { |
115 | - $filter = $this->object->createIndexFilterCategory( 0, 'relevance', '-', 1, 2, 'test' ); |
|
115 | + $filter = $this->object->createIndexFilterCategory(0, 'relevance', '-', 1, 2, 'test'); |
|
116 | 116 | |
117 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
117 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
118 | 118 | |
119 | 119 | $sort = $filter->getSortations(); |
120 | - if( ( $item = reset( $sort ) ) === false ) { |
|
121 | - throw new \RuntimeException( 'Sortation not set' ); |
|
120 | + if (($item = reset($sort)) === false) { |
|
121 | + throw new \RuntimeException('Sortation not set'); |
|
122 | 122 | } |
123 | 123 | |
124 | - $this->assertEquals( 'sort:index.catalog.position("test",["0"])', $item->getName() ); |
|
125 | - $this->assertEquals( '-', $item->getOperator() ); |
|
124 | + $this->assertEquals('sort:index.catalog.position("test",["0"])', $item->getName()); |
|
125 | + $this->assertEquals('-', $item->getOperator()); |
|
126 | 126 | |
127 | - $this->assertEquals( 1, $filter->getSliceStart() ); |
|
128 | - $this->assertEquals( 2, $filter->getSliceSize() ); |
|
127 | + $this->assertEquals(1, $filter->getSliceStart()); |
|
128 | + $this->assertEquals(2, $filter->getSliceSize()); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
132 | 132 | public function testCreateIndexFilterCategoryCode() |
133 | 133 | { |
134 | - $filter = $this->object->createIndexFilterCategory( 0, 'code' ); |
|
134 | + $filter = $this->object->createIndexFilterCategory(0, 'code'); |
|
135 | 135 | |
136 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
136 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
137 | 137 | |
138 | 138 | $sort = $filter->getSortations(); |
139 | - if( ( $item = reset( $sort ) ) === false ) { |
|
140 | - throw new \RuntimeException( 'Sortation not set' ); |
|
139 | + if (($item = reset($sort)) === false) { |
|
140 | + throw new \RuntimeException('Sortation not set'); |
|
141 | 141 | } |
142 | 142 | |
143 | - $this->assertStringStartsWith( 'product.code', $item->getName() ); |
|
143 | + $this->assertStringStartsWith('product.code', $item->getName()); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
147 | 147 | public function testCreateIndexFilterCategoryName() |
148 | 148 | { |
149 | - $filter = $this->object->createIndexFilterCategory( 0, 'name' ); |
|
149 | + $filter = $this->object->createIndexFilterCategory(0, 'name'); |
|
150 | 150 | |
151 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
151 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
152 | 152 | |
153 | 153 | $sort = $filter->getSortations(); |
154 | - if( ( $item = reset( $sort ) ) === false ) { |
|
155 | - throw new \RuntimeException( 'Sortation not set' ); |
|
154 | + if (($item = reset($sort)) === false) { |
|
155 | + throw new \RuntimeException('Sortation not set'); |
|
156 | 156 | } |
157 | 157 | |
158 | - $this->assertEquals( 'sort:index.text.value("default","de","name")', $item->getName() ); |
|
158 | + $this->assertEquals('sort:index.text.value("default","de","name")', $item->getName()); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | |
162 | 162 | public function testCreateIndexFilterCategoryPrice() |
163 | 163 | { |
164 | - $filter = $this->object->createIndexFilterCategory( 0, 'price' ); |
|
164 | + $filter = $this->object->createIndexFilterCategory(0, 'price'); |
|
165 | 165 | |
166 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
166 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
167 | 167 | |
168 | 168 | $sort = $filter->getSortations(); |
169 | - if( ( $item = reset( $sort ) ) === false ) { |
|
170 | - throw new \RuntimeException( 'Sortation not set' ); |
|
169 | + if (($item = reset($sort)) === false) { |
|
170 | + throw new \RuntimeException('Sortation not set'); |
|
171 | 171 | } |
172 | 172 | |
173 | - $this->assertStringStartsWith( 'sort:index.price.value("default","EUR","default")', $item->getName() ); |
|
173 | + $this->assertStringStartsWith('sort:index.price.value("default","EUR","default")', $item->getName()); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | |
177 | 177 | public function testCreateIndexFilterCategoryInvalidSortation() |
178 | 178 | { |
179 | - $filter = $this->object->createIndexFilterCategory( 0, 'failure' ); |
|
179 | + $filter = $this->object->createIndexFilterCategory(0, 'failure'); |
|
180 | 180 | |
181 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
182 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
181 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
182 | + $this->assertEquals(array(), $filter->getSortations()); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | |
186 | 186 | public function testAddIndexFilterCategory() |
187 | 187 | { |
188 | 188 | $filter = $this->object->createIndexFilter(); |
189 | - $filter = $this->object->addIndexFilterCategory( $filter, 0 ); |
|
189 | + $filter = $this->object->addIndexFilterCategory($filter, 0); |
|
190 | 190 | |
191 | 191 | $list = $filter->getConditions()->getExpressions(); |
192 | 192 | |
193 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
194 | - throw new \RuntimeException( 'Wrong expression' ); |
|
193 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
194 | + throw new \RuntimeException('Wrong expression'); |
|
195 | 195 | } |
196 | 196 | |
197 | - $this->assertEquals( 'index.catalog.id', $list[0]->getName() ); |
|
198 | - $this->assertEquals( array( 0 ), $list[0]->getValue() ); |
|
199 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
197 | + $this->assertEquals('index.catalog.id', $list[0]->getName()); |
|
198 | + $this->assertEquals(array(0), $list[0]->getValue()); |
|
199 | + $this->assertEquals(array(), $filter->getSortations()); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | |
203 | 203 | public function testCreateIndexFilterText() |
204 | 204 | { |
205 | - $filter = $this->object->createIndexFilterText( 'Espresso' ); |
|
205 | + $filter = $this->object->createIndexFilterText('Espresso'); |
|
206 | 206 | |
207 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
207 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
208 | 208 | |
209 | 209 | $list = $filter->getConditions()->getExpressions(); |
210 | 210 | |
211 | 211 | |
212 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
213 | - throw new \RuntimeException( 'Wrong expression' ); |
|
212 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
213 | + throw new \RuntimeException('Wrong expression'); |
|
214 | 214 | } |
215 | - $this->assertEquals( 'index.text.relevance("default","de","Espresso")', $list[0]->getName() ); |
|
216 | - $this->assertEquals( 0, $list[0]->getValue() ); |
|
215 | + $this->assertEquals('index.text.relevance("default","de","Espresso")', $list[0]->getName()); |
|
216 | + $this->assertEquals(0, $list[0]->getValue()); |
|
217 | 217 | |
218 | 218 | |
219 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
220 | - $this->assertEquals( 0, $filter->getSliceStart() ); |
|
221 | - $this->assertEquals( 100, $filter->getSliceSize() ); |
|
219 | + $this->assertEquals(array(), $filter->getSortations()); |
|
220 | + $this->assertEquals(0, $filter->getSliceStart()); |
|
221 | + $this->assertEquals(100, $filter->getSliceSize()); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | |
225 | 225 | public function testCreateIndexFilterTextRelevance() |
226 | 226 | { |
227 | - $filter = $this->object->createIndexFilterText( 'Espresso', 'relevance', '-', 1, 2, 'test' ); |
|
227 | + $filter = $this->object->createIndexFilterText('Espresso', 'relevance', '-', 1, 2, 'test'); |
|
228 | 228 | |
229 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
230 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
231 | - $this->assertEquals( 1, $filter->getSliceStart() ); |
|
232 | - $this->assertEquals( 2, $filter->getSliceSize() ); |
|
229 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
230 | + $this->assertEquals(array(), $filter->getSortations()); |
|
231 | + $this->assertEquals(1, $filter->getSliceStart()); |
|
232 | + $this->assertEquals(2, $filter->getSliceSize()); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | |
236 | 236 | public function testCreateIndexFilterTextCode() |
237 | 237 | { |
238 | - $filter = $this->object->createIndexFilterText( 'Espresso', 'code' ); |
|
238 | + $filter = $this->object->createIndexFilterText('Espresso', 'code'); |
|
239 | 239 | |
240 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
240 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
241 | 241 | |
242 | 242 | $sort = $filter->getSortations(); |
243 | - if( ( $item = reset( $sort ) ) === false ) { |
|
244 | - throw new \RuntimeException( 'Sortation not set' ); |
|
243 | + if (($item = reset($sort)) === false) { |
|
244 | + throw new \RuntimeException('Sortation not set'); |
|
245 | 245 | } |
246 | 246 | |
247 | - $this->assertEquals( 'product.code', $item->getName() ); |
|
247 | + $this->assertEquals('product.code', $item->getName()); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
251 | 251 | public function testCreateIndexFilterTextName() |
252 | 252 | { |
253 | - $filter = $this->object->createIndexFilterText( 'Espresso', 'name' ); |
|
253 | + $filter = $this->object->createIndexFilterText('Espresso', 'name'); |
|
254 | 254 | |
255 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
255 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
256 | 256 | |
257 | 257 | $sort = $filter->getSortations(); |
258 | - if( ( $item = reset( $sort ) ) === false ) { |
|
259 | - throw new \RuntimeException( 'Sortation not set' ); |
|
258 | + if (($item = reset($sort)) === false) { |
|
259 | + throw new \RuntimeException('Sortation not set'); |
|
260 | 260 | } |
261 | 261 | |
262 | - $this->assertEquals( 'sort:index.text.value("default","de","name")', $item->getName() ); |
|
262 | + $this->assertEquals('sort:index.text.value("default","de","name")', $item->getName()); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | |
266 | 266 | public function testCreateIndexFilterTextPrice() |
267 | 267 | { |
268 | - $filter = $this->object->createIndexFilterCategory( 'Espresso', 'price' ); |
|
268 | + $filter = $this->object->createIndexFilterCategory('Espresso', 'price'); |
|
269 | 269 | |
270 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
270 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
271 | 271 | |
272 | 272 | $sort = $filter->getSortations(); |
273 | - if( ( $item = reset( $sort ) ) === false ) { |
|
274 | - throw new \RuntimeException( 'Sortation not set' ); |
|
273 | + if (($item = reset($sort)) === false) { |
|
274 | + throw new \RuntimeException('Sortation not set'); |
|
275 | 275 | } |
276 | 276 | |
277 | - $this->assertStringStartsWith( 'sort:index.price.value("default","EUR","default")', $item->getName() ); |
|
277 | + $this->assertStringStartsWith('sort:index.price.value("default","EUR","default")', $item->getName()); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | |
281 | 281 | public function testCreateIndexFilterTextInvalidSortation() |
282 | 282 | { |
283 | - $filter = $this->object->createIndexFilterText( '', 'failure' ); |
|
283 | + $filter = $this->object->createIndexFilterText('', 'failure'); |
|
284 | 284 | |
285 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
286 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
285 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
286 | + $this->assertEquals(array(), $filter->getSortations()); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | |
290 | 290 | public function testAddIndexFilterText() |
291 | 291 | { |
292 | - $filter = $this->object->createIndexFilterText( 'Espresso' ); |
|
293 | - $filter = $this->object->addIndexFilterText( $filter, 'Espresso' ); |
|
292 | + $filter = $this->object->createIndexFilterText('Espresso'); |
|
293 | + $filter = $this->object->addIndexFilterText($filter, 'Espresso'); |
|
294 | 294 | |
295 | 295 | $list = $filter->getConditions()->getExpressions(); |
296 | 296 | |
297 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
298 | - throw new \RuntimeException( 'Wrong expression' ); |
|
297 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
298 | + throw new \RuntimeException('Wrong expression'); |
|
299 | 299 | } |
300 | 300 | |
301 | - $this->assertEquals( 'index.text.relevance("default","de","Espresso")', $list[0]->getName() ); |
|
302 | - $this->assertEquals( 0, $list[0]->getValue() ); |
|
303 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
301 | + $this->assertEquals('index.text.relevance("default","de","Espresso")', $list[0]->getName()); |
|
302 | + $this->assertEquals(0, $list[0]->getValue()); |
|
303 | + $this->assertEquals(array(), $filter->getSortations()); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | |
307 | 307 | public function testGetIndexItemsCategory() |
308 | 308 | { |
309 | - $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
309 | + $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
310 | 310 | $search = $catalogManager->createSearch(); |
311 | 311 | |
312 | - $search->setConditions( $search->compare( '==', 'catalog.code', 'new' ) ); |
|
313 | - $search->setSlice( 0, 1 ); |
|
314 | - $items = $catalogManager->searchItems( $search ); |
|
312 | + $search->setConditions($search->compare('==', 'catalog.code', 'new')); |
|
313 | + $search->setSlice(0, 1); |
|
314 | + $items = $catalogManager->searchItems($search); |
|
315 | 315 | |
316 | - if( ( $item = reset( $items ) ) === false ) { |
|
317 | - throw new \RuntimeException( 'Catalog item not found' ); |
|
316 | + if (($item = reset($items)) === false) { |
|
317 | + throw new \RuntimeException('Catalog item not found'); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | $total = 0; |
321 | - $filter = $this->object->createIndexFilterCategory( $item->getId(), 'position', '+', 1, 1 ); |
|
322 | - $results = $this->object->getIndexItems( $filter, array(), $total ); |
|
321 | + $filter = $this->object->createIndexFilterCategory($item->getId(), 'position', '+', 1, 1); |
|
322 | + $results = $this->object->getIndexItems($filter, array(), $total); |
|
323 | 323 | |
324 | - $this->assertEquals( 3, $total ); |
|
325 | - $this->assertEquals( 1, count( $results ) ); |
|
324 | + $this->assertEquals(3, $total); |
|
325 | + $this->assertEquals(1, count($results)); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | |
329 | 329 | public function testGetIndexItemsText() |
330 | 330 | { |
331 | 331 | $total = 0; |
332 | - $filter = $this->object->createIndexFilterText( 'Expresso', 'relevance', '+', 0, 1, 'unittype13' ); |
|
333 | - $results = $this->object->getIndexItems( $filter, array(), $total ); |
|
332 | + $filter = $this->object->createIndexFilterText('Expresso', 'relevance', '+', 0, 1, 'unittype13'); |
|
333 | + $results = $this->object->getIndexItems($filter, array(), $total); |
|
334 | 334 | |
335 | - $this->assertEquals( 2, $total ); |
|
336 | - $this->assertEquals( 1, count( $results ) ); |
|
335 | + $this->assertEquals(2, $total); |
|
336 | + $this->assertEquals(1, count($results)); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | |
340 | 340 | public function testCreateTextFilter() |
341 | 341 | { |
342 | - $filter = $this->object->createTextFilter( 'Expresso', 'name', '+', 0, 1 ); |
|
342 | + $filter = $this->object->createTextFilter('Expresso', 'name', '+', 0, 1); |
|
343 | 343 | |
344 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
345 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Expression\\Combine\\Iface', $filter->getConditions() ); |
|
346 | - $this->assertEquals( 3, count( $filter->getConditions()->getExpressions() ) ); |
|
344 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
345 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Expression\\Combine\\Iface', $filter->getConditions()); |
|
346 | + $this->assertEquals(3, count($filter->getConditions()->getExpressions())); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | |
350 | 350 | public function testGetTextListName() |
351 | 351 | { |
352 | - $filter = $this->object->createTextFilter( 'Cafe Noire', 'relevance', '-', 0, 25, 'unittype19', 'name' ); |
|
353 | - $results = $this->object->getTextList( $filter ); |
|
352 | + $filter = $this->object->createTextFilter('Cafe Noire', 'relevance', '-', 0, 25, 'unittype19', 'name'); |
|
353 | + $results = $this->object->getTextList($filter); |
|
354 | 354 | |
355 | - $this->assertEquals( 1, count( $results ) ); |
|
356 | - $this->assertContains( 'Cafe Noire Cappuccino', $results ); |
|
355 | + $this->assertEquals(1, count($results)); |
|
356 | + $this->assertContains('Cafe Noire Cappuccino', $results); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | } |
@@ -41,15 +41,15 @@ discard block |
||
41 | 41 | * @param string $stocktype Unique code of the stock type to deliver the products from |
42 | 42 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
43 | 43 | */ |
44 | - public function addProduct( $prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
44 | + public function addProduct($prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
45 | 45 | array $configAttributeIds = array(), array $hiddenAttributeIds = array(), array $customAttributeValues = array(), |
46 | - $stocktype = 'default' ) |
|
46 | + $stocktype = 'default') |
|
47 | 47 | { |
48 | 48 | $context = $this->getContext(); |
49 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
50 | - $productItem = $productManager->getItem( $prodid ); |
|
49 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
50 | + $productItem = $productManager->getItem($prodid); |
|
51 | 51 | |
52 | - if( $productItem->getType() !== 'bundle' ) |
|
52 | + if ($productItem->getType() !== 'bundle') |
|
53 | 53 | { |
54 | 54 | return $this->getController()->addProduct( |
55 | 55 | $prodid, $quantity, $options, $variantAttributeIds, $configAttributeIds, |
@@ -57,30 +57,30 @@ discard block |
||
57 | 57 | ); |
58 | 58 | } |
59 | 59 | |
60 | - $productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ) ); |
|
60 | + $productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text')); |
|
61 | 61 | |
62 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
63 | - $orderBaseProductItem->copyFrom( $productItem ); |
|
64 | - $orderBaseProductItem->setQuantity( $quantity ); |
|
65 | - $orderBaseProductItem->setStockType( $stocktype ); |
|
62 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
63 | + $orderBaseProductItem->copyFrom($productItem); |
|
64 | + $orderBaseProductItem->setQuantity($quantity); |
|
65 | + $orderBaseProductItem->setStockType($stocktype); |
|
66 | 66 | |
67 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
68 | - $this->addBundleProducts( $orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype ); |
|
67 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
68 | + $this->addBundleProducts($orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype); |
|
69 | 69 | |
70 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
71 | - $price = $priceManager->getLowestPrice( $prices, $quantity ); |
|
70 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
71 | + $price = $priceManager->getLowestPrice($prices, $quantity); |
|
72 | 72 | |
73 | - $attr = $this->createOrderProductAttributes( $price, $prodid, $quantity, $configAttributeIds, 'config' ); |
|
74 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, $hiddenAttributeIds, 'hidden' ) ); |
|
75 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, array_keys( $customAttributeValues ), 'custom', $customAttributeValues ) ); |
|
73 | + $attr = $this->createOrderProductAttributes($price, $prodid, $quantity, $configAttributeIds, 'config'); |
|
74 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, $hiddenAttributeIds, 'hidden')); |
|
75 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, array_keys($customAttributeValues), 'custom', $customAttributeValues)); |
|
76 | 76 | |
77 | 77 | // remove product rebate of original price in favor to rebates granted for the order |
78 | - $price->setRebate( '0.00' ); |
|
78 | + $price->setRebate('0.00'); |
|
79 | 79 | |
80 | - $orderBaseProductItem->setPrice( $price ); |
|
81 | - $orderBaseProductItem->setAttributes( $attr ); |
|
80 | + $orderBaseProductItem->setPrice($price); |
|
81 | + $orderBaseProductItem->setAttributes($attr); |
|
82 | 82 | |
83 | - $this->getController()->get()->addProduct( $orderBaseProductItem ); |
|
83 | + $this->getController()->get()->addProduct($orderBaseProductItem); |
|
84 | 84 | $this->getController()->save(); |
85 | 85 | } |
86 | 86 | |
@@ -93,43 +93,43 @@ discard block |
||
93 | 93 | * @param array $variantAttributeIds List of product variant attribute IDs |
94 | 94 | * @param string $stocktype |
95 | 95 | */ |
96 | - protected function addBundleProducts( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
97 | - \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype ) |
|
96 | + protected function addBundleProducts(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
97 | + \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype) |
|
98 | 98 | { |
99 | 99 | $quantity = $orderBaseProductItem->getQuantity(); |
100 | 100 | $products = $subProductIds = $orderProducts = array(); |
101 | - $orderProductManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product' ); |
|
101 | + $orderProductManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product'); |
|
102 | 102 | |
103 | - foreach( $productItem->getRefItems( 'product', null, 'default' ) as $item ) { |
|
103 | + foreach ($productItem->getRefItems('product', null, 'default') as $item) { |
|
104 | 104 | $subProductIds[] = $item->getId(); |
105 | 105 | } |
106 | 106 | |
107 | - if( count( $subProductIds ) > 0 ) |
|
107 | + if (count($subProductIds) > 0) |
|
108 | 108 | { |
109 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
109 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
110 | 110 | |
111 | - $search = $productManager->createSearch( true ); |
|
111 | + $search = $productManager->createSearch(true); |
|
112 | 112 | $expr = array( |
113 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
113 | + $search->compare('==', 'product.id', $subProductIds), |
|
114 | 114 | $search->getConditions(), |
115 | 115 | ); |
116 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
116 | + $search->setConditions($search->combine('&&', $expr)); |
|
117 | 117 | |
118 | - $products = $productManager->searchItems( $search, array( 'attribute', 'media', 'price', 'text' ) ); |
|
118 | + $products = $productManager->searchItems($search, array('attribute', 'media', 'price', 'text')); |
|
119 | 119 | } |
120 | 120 | |
121 | - foreach( $products as $product ) |
|
121 | + foreach ($products as $product) |
|
122 | 122 | { |
123 | - $prices = $product->getRefItems( 'price', 'default', 'default' ); |
|
123 | + $prices = $product->getRefItems('price', 'default', 'default'); |
|
124 | 124 | |
125 | 125 | $orderProduct = $orderProductManager->createItem(); |
126 | - $orderProduct->copyFrom( $product ); |
|
127 | - $orderProduct->setStockType( $stocktype ); |
|
128 | - $orderProduct->setPrice( $this->calcPrice( $orderProduct, $prices, $quantity ) ); |
|
126 | + $orderProduct->copyFrom($product); |
|
127 | + $orderProduct->setStockType($stocktype); |
|
128 | + $orderProduct->setPrice($this->calcPrice($orderProduct, $prices, $quantity)); |
|
129 | 129 | |
130 | 130 | $orderProducts[] = $orderProduct; |
131 | 131 | } |
132 | 132 | |
133 | - $orderBaseProductItem->setProducts( $orderProducts ); |
|
133 | + $orderBaseProductItem->setProducts($orderProducts); |
|
134 | 134 | } |
135 | 135 | } |
@@ -41,15 +41,15 @@ discard block |
||
41 | 41 | * @param string $stocktype Unique code of the stock type to deliver the products from |
42 | 42 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
43 | 43 | */ |
44 | - public function addProduct( $prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
44 | + public function addProduct($prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
45 | 45 | array $configAttributeIds = array(), array $hiddenAttributeIds = array(), array $customAttributeValues = array(), |
46 | - $stocktype = 'default' ) |
|
46 | + $stocktype = 'default') |
|
47 | 47 | { |
48 | 48 | $context = $this->getContext(); |
49 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
50 | - $productItem = $productManager->getItem( $prodid ); |
|
49 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
50 | + $productItem = $productManager->getItem($prodid); |
|
51 | 51 | |
52 | - if( $productItem->getType() !== 'select' ) |
|
52 | + if ($productItem->getType() !== 'select') |
|
53 | 53 | { |
54 | 54 | return $this->getController()->addProduct( |
55 | 55 | $prodid, $quantity, $options, $variantAttributeIds, $configAttributeIds, |
@@ -57,31 +57,31 @@ discard block |
||
57 | 57 | ); |
58 | 58 | } |
59 | 59 | |
60 | - $productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ) ); |
|
60 | + $productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text')); |
|
61 | 61 | |
62 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
63 | - $orderBaseProductItem->copyFrom( $productItem ); |
|
64 | - $orderBaseProductItem->setQuantity( $quantity ); |
|
65 | - $orderBaseProductItem->setStockType( $stocktype ); |
|
62 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
63 | + $orderBaseProductItem->copyFrom($productItem); |
|
64 | + $orderBaseProductItem->setQuantity($quantity); |
|
65 | + $orderBaseProductItem->setStockType($stocktype); |
|
66 | 66 | |
67 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
68 | - $attr = $this->getVariantDetails( $orderBaseProductItem, $productItem, $prices, $variantAttributeIds, $options ); |
|
69 | - $prodIds = array( $prodid, $productItem->getId() ); |
|
67 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
68 | + $attr = $this->getVariantDetails($orderBaseProductItem, $productItem, $prices, $variantAttributeIds, $options); |
|
69 | + $prodIds = array($prodid, $productItem->getId()); |
|
70 | 70 | |
71 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
72 | - $price = $priceManager->getLowestPrice( $prices, $quantity ); |
|
71 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
72 | + $price = $priceManager->getLowestPrice($prices, $quantity); |
|
73 | 73 | |
74 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodIds, $quantity, $configAttributeIds, 'config' ) ); |
|
75 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodIds, $quantity, $hiddenAttributeIds, 'hidden' ) ); |
|
76 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodIds, $quantity, array_keys( $customAttributeValues ), 'custom', $customAttributeValues ) ); |
|
74 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodIds, $quantity, $configAttributeIds, 'config')); |
|
75 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodIds, $quantity, $hiddenAttributeIds, 'hidden')); |
|
76 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodIds, $quantity, array_keys($customAttributeValues), 'custom', $customAttributeValues)); |
|
77 | 77 | |
78 | 78 | // remove product rebate of original price in favor to rebates granted for the order |
79 | - $price->setRebate( '0.00' ); |
|
79 | + $price->setRebate('0.00'); |
|
80 | 80 | |
81 | - $orderBaseProductItem->setPrice( $price ); |
|
82 | - $orderBaseProductItem->setAttributes( $attr ); |
|
81 | + $orderBaseProductItem->setPrice($price); |
|
82 | + $orderBaseProductItem->setAttributes($attr); |
|
83 | 83 | |
84 | - $this->getController()->get()->addProduct( $orderBaseProductItem ); |
|
84 | + $this->getController()->get()->addProduct($orderBaseProductItem); |
|
85 | 85 | $this->getController()->save(); |
86 | 86 | } |
87 | 87 | |
@@ -97,50 +97,50 @@ discard block |
||
97 | 97 | * @return \Aimeos\MShop\Order\Item\Base\Product\Attribute\Iface[] List of order product attributes |
98 | 98 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If no product variant is found |
99 | 99 | */ |
100 | - protected function getVariantDetails( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
101 | - \Aimeos\MShop\Product\Item\Iface &$productItem, array &$prices, array $variantAttributeIds, array $options ) |
|
100 | + protected function getVariantDetails(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
101 | + \Aimeos\MShop\Product\Item\Iface & $productItem, array &$prices, array $variantAttributeIds, array $options) |
|
102 | 102 | { |
103 | 103 | $attr = array(); |
104 | - $productItems = $this->getProductVariants( $productItem, $variantAttributeIds ); |
|
104 | + $productItems = $this->getProductVariants($productItem, $variantAttributeIds); |
|
105 | 105 | |
106 | - if( count( $productItems ) > 1 ) |
|
106 | + if (count($productItems) > 1) |
|
107 | 107 | { |
108 | - $msg = sprintf( 'No unique article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
|
109 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
108 | + $msg = sprintf('No unique article found for selected attributes and product ID "%1$s"', $productItem->getId()); |
|
109 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
110 | 110 | } |
111 | - else if( ( $result = reset( $productItems ) ) !== false ) // count == 1 |
|
111 | + else if (($result = reset($productItems)) !== false) // count == 1 |
|
112 | 112 | { |
113 | 113 | $productItem = $result; |
114 | - $orderBaseProductItem->setProductCode( $productItem->getCode() ); |
|
114 | + $orderBaseProductItem->setProductCode($productItem->getCode()); |
|
115 | 115 | |
116 | - $subprices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
116 | + $subprices = $productItem->getRefItems('price', 'default', 'default'); |
|
117 | 117 | |
118 | - if( !empty( $subprices ) ) { |
|
118 | + if (!empty($subprices)) { |
|
119 | 119 | $prices = $subprices; |
120 | 120 | } |
121 | 121 | |
122 | - $submedia = $productItem->getRefItems( 'media', 'default', 'default' ); |
|
122 | + $submedia = $productItem->getRefItems('media', 'default', 'default'); |
|
123 | 123 | |
124 | - if( ( $mediaItem = reset( $submedia ) ) !== false ) { |
|
125 | - $orderBaseProductItem->setMediaUrl( $mediaItem->getPreview() ); |
|
124 | + if (($mediaItem = reset($submedia)) !== false) { |
|
125 | + $orderBaseProductItem->setMediaUrl($mediaItem->getPreview()); |
|
126 | 126 | } |
127 | 127 | |
128 | - $orderProductAttrManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product/attribute' ); |
|
129 | - $variantAttributes = $productItem->getRefItems( 'attribute', null, 'variant' ); |
|
128 | + $orderProductAttrManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product/attribute'); |
|
129 | + $variantAttributes = $productItem->getRefItems('attribute', null, 'variant'); |
|
130 | 130 | |
131 | - foreach( $this->getAttributes( array_keys( $variantAttributes ), array( 'text' ) ) as $attrItem ) |
|
131 | + foreach ($this->getAttributes(array_keys($variantAttributes), array('text')) as $attrItem) |
|
132 | 132 | { |
133 | 133 | $orderAttributeItem = $orderProductAttrManager->createItem(); |
134 | - $orderAttributeItem->copyFrom( $attrItem ); |
|
135 | - $orderAttributeItem->setType( 'variant' ); |
|
134 | + $orderAttributeItem->copyFrom($attrItem); |
|
135 | + $orderAttributeItem->setType('variant'); |
|
136 | 136 | |
137 | 137 | $attr[] = $orderAttributeItem; |
138 | 138 | } |
139 | 139 | } |
140 | - else if( !isset( $options['variant'] ) || $options['variant'] != false ) // count == 0 |
|
140 | + else if (!isset($options['variant']) || $options['variant'] != false) // count == 0 |
|
141 | 141 | { |
142 | - $msg = sprintf( 'No article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
|
143 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
142 | + $msg = sprintf('No article found for selected attributes and product ID "%1$s"', $productItem->getId()); |
|
143 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | return $attr; |
@@ -31,42 +31,42 @@ discard block |
||
31 | 31 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
32 | 32 | * @since 2017.03 |
33 | 33 | */ |
34 | - public function addFilterAttribute( \Aimeos\MW\Criteria\Iface $filter, array $attrIds, array $optIds, array $oneIds ) |
|
34 | + public function addFilterAttribute(\Aimeos\MW\Criteria\Iface $filter, array $attrIds, array $optIds, array $oneIds) |
|
35 | 35 | { |
36 | - if( !empty( $attrIds ) ) |
|
36 | + if (!empty($attrIds)) |
|
37 | 37 | { |
38 | - $attrIds = $this->validateIds( $attrIds ); |
|
38 | + $attrIds = $this->validateIds($attrIds); |
|
39 | 39 | |
40 | - $func = $filter->createFunction( 'index.attributeaggregate', array( $attrIds ) ); |
|
40 | + $func = $filter->createFunction('index.attributeaggregate', array($attrIds)); |
|
41 | 41 | $expr = array( |
42 | - $filter->compare( '==', $func, count( $attrIds ) ), |
|
42 | + $filter->compare('==', $func, count($attrIds)), |
|
43 | 43 | $filter->getConditions(), |
44 | 44 | ); |
45 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
45 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
46 | 46 | } |
47 | 47 | |
48 | - if( !empty( $optIds ) ) |
|
48 | + if (!empty($optIds)) |
|
49 | 49 | { |
50 | - $optIds = $this->validateIds( $optIds ); |
|
50 | + $optIds = $this->validateIds($optIds); |
|
51 | 51 | |
52 | - $func = $filter->createFunction( 'index.attributeaggregate', array( $optIds ) ); |
|
52 | + $func = $filter->createFunction('index.attributeaggregate', array($optIds)); |
|
53 | 53 | $expr = array( |
54 | - $filter->compare( '>', $func, 0 ), |
|
54 | + $filter->compare('>', $func, 0), |
|
55 | 55 | $filter->getConditions(), |
56 | 56 | ); |
57 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
57 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
58 | 58 | } |
59 | 59 | |
60 | - foreach( $oneIds as $type => $list ) |
|
60 | + foreach ($oneIds as $type => $list) |
|
61 | 61 | { |
62 | - if( ( $list = $this->validateIds( (array) $list ) ) !== array() ) |
|
62 | + if (($list = $this->validateIds((array) $list)) !== array()) |
|
63 | 63 | { |
64 | - $func = $filter->createFunction( 'index.attributeaggregate', array( $list ) ); |
|
64 | + $func = $filter->createFunction('index.attributeaggregate', array($list)); |
|
65 | 65 | $expr = array( |
66 | - $filter->compare( '>', $func, 0 ), |
|
66 | + $filter->compare('>', $func, 0), |
|
67 | 67 | $filter->getConditions(), |
68 | 68 | ); |
69 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
69 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
@@ -86,38 +86,38 @@ discard block |
||
86 | 86 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
87 | 87 | * @since 2017.03 |
88 | 88 | */ |
89 | - public function addFilterCategory( \Aimeos\MW\Criteria\Iface $filter, $catId, |
|
90 | - $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default' ) |
|
89 | + public function addFilterCategory(\Aimeos\MW\Criteria\Iface $filter, $catId, |
|
90 | + $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default') |
|
91 | 91 | { |
92 | - $catIds = ( !is_array( $catId ) ? explode( ',', $catId ) : $catId ); |
|
92 | + $catIds = (!is_array($catId) ? explode(',', $catId) : $catId); |
|
93 | 93 | |
94 | - if( $level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ) |
|
94 | + if ($level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE) |
|
95 | 95 | { |
96 | 96 | $list = array(); |
97 | - $cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'catalog' ); |
|
97 | + $cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'catalog'); |
|
98 | 98 | |
99 | - foreach( $catIds as $catId ) |
|
99 | + foreach ($catIds as $catId) |
|
100 | 100 | { |
101 | - $tree = $cntl->getCatalogTree( $catId, array(), $level ); |
|
102 | - $list = array_merge( $list, $this->getCatalogIdsFromTree( $tree ) ); |
|
101 | + $tree = $cntl->getCatalogTree($catId, array(), $level); |
|
102 | + $list = array_merge($list, $this->getCatalogIdsFromTree($tree)); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | $catIds = $list; |
106 | 106 | } |
107 | 107 | |
108 | - $expr = array( $filter->compare( '==', 'index.catalog.id', array_unique( $catIds ) ) ); |
|
108 | + $expr = array($filter->compare('==', 'index.catalog.id', array_unique($catIds))); |
|
109 | 109 | $expr[] = $filter->getConditions(); |
110 | 110 | |
111 | - if( $sort === 'relevance' ) |
|
111 | + if ($sort === 'relevance') |
|
112 | 112 | { |
113 | - $cmpfunc = $filter->createFunction( 'index.catalog.position', array( $listtype, $catIds ) ); |
|
114 | - $expr[] = $filter->compare( '>=', $cmpfunc, 0 ); |
|
113 | + $cmpfunc = $filter->createFunction('index.catalog.position', array($listtype, $catIds)); |
|
114 | + $expr[] = $filter->compare('>=', $cmpfunc, 0); |
|
115 | 115 | |
116 | - $sortfunc = $filter->createFunction( 'sort:index.catalog.position', array( $listtype, $catIds ) ); |
|
117 | - $filter->setSortations( array( $filter->sort( $direction, $sortfunc ) ) ); |
|
116 | + $sortfunc = $filter->createFunction('sort:index.catalog.position', array($listtype, $catIds)); |
|
117 | + $filter->setSortations(array($filter->sort($direction, $sortfunc))); |
|
118 | 118 | } |
119 | 119 | |
120 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
120 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
121 | 121 | |
122 | 122 | return $filter; |
123 | 123 | } |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
135 | 135 | * @since 2017.03 |
136 | 136 | */ |
137 | - public function addFilterText( \Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default' ) |
|
137 | + public function addFilterText(\Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default') |
|
138 | 138 | { |
139 | 139 | $langid = $this->getContext()->getLocale()->getLanguageId(); |
140 | - $cmpfunc = $filter->createFunction( 'index.text.relevance', array( $listtype, $langid, $input ) ); |
|
141 | - $expr = array( $filter->compare( '>', $cmpfunc, 0 ), $filter->getConditions() ); |
|
140 | + $cmpfunc = $filter->createFunction('index.text.relevance', array($listtype, $langid, $input)); |
|
141 | + $expr = array($filter->compare('>', $cmpfunc, 0), $filter->getConditions()); |
|
142 | 142 | |
143 | - return $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
143 | + return $filter->setConditions($filter->combine('&&', $expr)); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | * @return array Associative list of key values as key and the product count for this key as value |
153 | 153 | * @since 2017.03 |
154 | 154 | */ |
155 | - public function aggregate( \Aimeos\MW\Criteria\Iface $filter, $key ) |
|
155 | + public function aggregate(\Aimeos\MW\Criteria\Iface $filter, $key) |
|
156 | 156 | { |
157 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->aggregate( $filter, $key ); |
|
157 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->aggregate($filter, $key); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -169,46 +169,46 @@ discard block |
||
169 | 169 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
170 | 170 | * @since 2017.03 |
171 | 171 | */ |
172 | - public function createFilter( $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' ) |
|
172 | + public function createFilter($sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default') |
|
173 | 173 | { |
174 | 174 | $sortations = array(); |
175 | 175 | $context = $this->getContext(); |
176 | 176 | |
177 | - $search = \Aimeos\MShop\Factory::createManager( $context, 'index' )->createSearch( true ); |
|
178 | - $expr = array( $search->compare( '!=', 'index.catalog.id', null ) ); |
|
177 | + $search = \Aimeos\MShop\Factory::createManager($context, 'index')->createSearch(true); |
|
178 | + $expr = array($search->compare('!=', 'index.catalog.id', null)); |
|
179 | 179 | |
180 | - switch( $sort ) |
|
180 | + switch ($sort) |
|
181 | 181 | { |
182 | 182 | case 'code': |
183 | - $sortations[] = $search->sort( $direction, 'product.code' ); |
|
183 | + $sortations[] = $search->sort($direction, 'product.code'); |
|
184 | 184 | break; |
185 | 185 | |
186 | 186 | case 'name': |
187 | 187 | $langid = $context->getLocale()->getLanguageId(); |
188 | 188 | |
189 | - $cmpfunc = $search->createFunction( 'index.text.value', array( $listtype, $langid, 'name', 'product' ) ); |
|
190 | - $expr[] = $search->compare( '>=', $cmpfunc, '' ); |
|
189 | + $cmpfunc = $search->createFunction('index.text.value', array($listtype, $langid, 'name', 'product')); |
|
190 | + $expr[] = $search->compare('>=', $cmpfunc, ''); |
|
191 | 191 | |
192 | - $sortfunc = $search->createFunction( 'sort:index.text.value', array( $listtype, $langid, 'name' ) ); |
|
193 | - $sortations[] = $search->sort( $direction, $sortfunc ); |
|
192 | + $sortfunc = $search->createFunction('sort:index.text.value', array($listtype, $langid, 'name')); |
|
193 | + $sortations[] = $search->sort($direction, $sortfunc); |
|
194 | 194 | break; |
195 | 195 | |
196 | 196 | case 'price': |
197 | 197 | $currencyid = $context->getLocale()->getCurrencyId(); |
198 | 198 | |
199 | - $cmpfunc = $search->createFunction( 'index.price.value', array( $listtype, $currencyid, 'default' ) ); |
|
200 | - $expr[] = $search->compare( '>=', $cmpfunc, '0.00' ); |
|
199 | + $cmpfunc = $search->createFunction('index.price.value', array($listtype, $currencyid, 'default')); |
|
200 | + $expr[] = $search->compare('>=', $cmpfunc, '0.00'); |
|
201 | 201 | |
202 | - $sortfunc = $search->createFunction( 'sort:index.price.value', array( $listtype, $currencyid, 'default' ) ); |
|
203 | - $sortations[] = $search->sort( $direction, $sortfunc ); |
|
202 | + $sortfunc = $search->createFunction('sort:index.price.value', array($listtype, $currencyid, 'default')); |
|
203 | + $sortations[] = $search->sort($direction, $sortfunc); |
|
204 | 204 | break; |
205 | 205 | } |
206 | 206 | |
207 | 207 | $expr[] = $search->getConditions(); |
208 | 208 | |
209 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
210 | - $search->setSortations( $sortations ); |
|
211 | - $search->setSlice( $start, $size ); |
|
209 | + $search->setConditions($search->combine('&&', $expr)); |
|
210 | + $search->setSortations($sortations); |
|
211 | + $search->setSlice($start, $size); |
|
212 | 212 | |
213 | 213 | return $search; |
214 | 214 | } |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | * @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items |
223 | 223 | * @since 2017.03 |
224 | 224 | */ |
225 | - public function getItem( $productId, array $domains = array( 'attribute', 'media', 'price', 'product', 'product/property', 'text' ) ) |
|
225 | + public function getItem($productId, array $domains = array('attribute', 'media', 'price', 'product', 'product/property', 'text')) |
|
226 | 226 | { |
227 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' )->getItem( $productId, $domains ); |
|
227 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'product')->getItem($productId, $domains); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | |
@@ -236,19 +236,19 @@ discard block |
||
236 | 236 | * @return \Aimeos\MShop\Product\Item\Iface[] Associative list of product IDs as keys and product items as values |
237 | 237 | * @since 2017.03 |
238 | 238 | */ |
239 | - public function getItems( array $productIds, array $domains = array( 'media', 'price', 'text' ) ) |
|
239 | + public function getItems(array $productIds, array $domains = array('media', 'price', 'text')) |
|
240 | 240 | { |
241 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
241 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
242 | 242 | |
243 | - $search = $manager->createSearch( true ); |
|
243 | + $search = $manager->createSearch(true); |
|
244 | 244 | $expr = array( |
245 | - $search->compare( '==', 'product.id', $productIds ), |
|
245 | + $search->compare('==', 'product.id', $productIds), |
|
246 | 246 | $search->getConditions(), |
247 | 247 | ); |
248 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
249 | - $search->setSlice( 0, count( $productIds ) ); |
|
248 | + $search->setConditions($search->combine('&&', $expr)); |
|
249 | + $search->setSlice(0, count($productIds)); |
|
250 | 250 | |
251 | - return $manager->searchItems( $search, $domains ); |
|
251 | + return $manager->searchItems($search, $domains); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface |
262 | 262 | * @since 2017.03 |
263 | 263 | */ |
264 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null ) |
|
264 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null) |
|
265 | 265 | { |
266 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->searchItems( $filter, $domains, $total ); |
|
266 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->searchItems($filter, $domains, $total); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -273,12 +273,12 @@ discard block |
||
273 | 273 | * @param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item with children |
274 | 274 | * @return array List of catalog IDs |
275 | 275 | */ |
276 | - protected function getCatalogIdsFromTree( \Aimeos\MShop\Catalog\Item\Iface $item ) |
|
276 | + protected function getCatalogIdsFromTree(\Aimeos\MShop\Catalog\Item\Iface $item) |
|
277 | 277 | { |
278 | - $list = array( $item->getId() ); |
|
278 | + $list = array($item->getId()); |
|
279 | 279 | |
280 | - foreach( $item->getChildren() as $child ) { |
|
281 | - $list = array_merge( $list, $this->getCatalogIdsFromTree( $child ) ); |
|
280 | + foreach ($item->getChildren() as $child) { |
|
281 | + $list = array_merge($list, $this->getCatalogIdsFromTree($child)); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | return $list; |
@@ -291,13 +291,13 @@ discard block |
||
291 | 291 | * @param array $ids List of IDs to validate |
292 | 292 | * @return array List of validated IDs |
293 | 293 | */ |
294 | - protected function validateIds( array $ids ) |
|
294 | + protected function validateIds(array $ids) |
|
295 | 295 | { |
296 | 296 | $list = array(); |
297 | 297 | |
298 | - foreach( $ids as $id ) |
|
298 | + foreach ($ids as $id) |
|
299 | 299 | { |
300 | - if( $id != '' ) { |
|
300 | + if ($id != '') { |
|
301 | 301 | $list[] = (int) $id; |
302 | 302 | } |
303 | 303 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
31 | 31 | * @since 2017.03 |
32 | 32 | */ |
33 | - public function addFilterAttribute( \Aimeos\MW\Criteria\Iface $filter, array $attrIds, array $optIds, array $oneIds ); |
|
33 | + public function addFilterAttribute(\Aimeos\MW\Criteria\Iface $filter, array $attrIds, array $optIds, array $oneIds); |
|
34 | 34 | |
35 | 35 | |
36 | 36 | /** |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
46 | 46 | * @since 2017.03 |
47 | 47 | */ |
48 | - public function addFilterCategory( \Aimeos\MW\Criteria\Iface $filter, $catId, |
|
49 | - $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default' ); |
|
48 | + public function addFilterCategory(\Aimeos\MW\Criteria\Iface $filter, $catId, |
|
49 | + $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default'); |
|
50 | 50 | |
51 | 51 | |
52 | 52 | /** |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
61 | 61 | * @since 2017.03 |
62 | 62 | */ |
63 | - public function addFilterText( \Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default' ); |
|
63 | + public function addFilterText(\Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default'); |
|
64 | 64 | |
65 | 65 | |
66 | 66 | /** |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @return array Associative list of key values as key and the product count for this key as value |
72 | 72 | * @since 2017.03 |
73 | 73 | */ |
74 | - public function aggregate( \Aimeos\MW\Criteria\Iface $filter, $key ); |
|
74 | + public function aggregate(\Aimeos\MW\Criteria\Iface $filter, $key); |
|
75 | 75 | |
76 | 76 | |
77 | 77 | /** |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
86 | 86 | * @since 2017.03 |
87 | 87 | */ |
88 | - public function createFilter( $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' ); |
|
88 | + public function createFilter($sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default'); |
|
89 | 89 | |
90 | 90 | |
91 | 91 | /** |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items |
97 | 97 | * @since 2017.03 |
98 | 98 | */ |
99 | - public function getItem( $productId, array $domains = array( 'attribute', 'media', 'price', 'product', 'product/property', 'text' ) ); |
|
99 | + public function getItem($productId, array $domains = array('attribute', 'media', 'price', 'product', 'product/property', 'text')); |
|
100 | 100 | |
101 | 101 | |
102 | 102 | /** |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @return \Aimeos\MShop\Product\Item\Iface[] Associative list of product IDs as keys and product items as values |
108 | 108 | * @since 2017.03 |
109 | 109 | */ |
110 | - public function getItems( array $productIds, array $domains = array( 'media', 'price', 'text' ) ); |
|
110 | + public function getItems(array $productIds, array $domains = array('media', 'price', 'text')); |
|
111 | 111 | |
112 | 112 | |
113 | 113 | /** |
@@ -119,5 +119,5 @@ discard block |
||
119 | 119 | * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface |
120 | 120 | * @since 2017.03 |
121 | 121 | */ |
122 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null ); |
|
122 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null); |
|
123 | 123 | } |
@@ -15,31 +15,31 @@ |
||
15 | 15 | { |
16 | 16 | $target = '\\Aimeos\\Controller\\Frontend\\Product\\Iface'; |
17 | 17 | |
18 | - $controller = \Aimeos\Controller\Frontend\Product\Factory::createController( \TestHelperFrontend::getContext() ); |
|
19 | - $this->assertInstanceOf( $target, $controller ); |
|
18 | + $controller = \Aimeos\Controller\Frontend\Product\Factory::createController(\TestHelperFrontend::getContext()); |
|
19 | + $this->assertInstanceOf($target, $controller); |
|
20 | 20 | |
21 | - $controller = \Aimeos\Controller\Frontend\Product\Factory::createController( \TestHelperFrontend::getContext(), 'Standard' ); |
|
22 | - $this->assertInstanceOf( $target, $controller ); |
|
21 | + $controller = \Aimeos\Controller\Frontend\Product\Factory::createController(\TestHelperFrontend::getContext(), 'Standard'); |
|
22 | + $this->assertInstanceOf($target, $controller); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | |
26 | 26 | public function testCreateControllerInvalidImplementation() |
27 | 27 | { |
28 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' ); |
|
29 | - \Aimeos\Controller\Frontend\Product\Factory::createController( \TestHelperFrontend::getContext(), 'Invalid' ); |
|
28 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception'); |
|
29 | + \Aimeos\Controller\Frontend\Product\Factory::createController(\TestHelperFrontend::getContext(), 'Invalid'); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | |
33 | 33 | public function testCreateControllerInvalidName() |
34 | 34 | { |
35 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' ); |
|
36 | - \Aimeos\Controller\Frontend\Product\Factory::createController( \TestHelperFrontend::getContext(), '%^' ); |
|
35 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception'); |
|
36 | + \Aimeos\Controller\Frontend\Product\Factory::createController(\TestHelperFrontend::getContext(), '%^'); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | |
40 | 40 | public function testCreateControllerNotExisting() |
41 | 41 | { |
42 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' ); |
|
43 | - \Aimeos\Controller\Frontend\Product\Factory::createController( \TestHelperFrontend::getContext(), 'notexist' ); |
|
42 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception'); |
|
43 | + \Aimeos\Controller\Frontend\Product\Factory::createController(\TestHelperFrontend::getContext(), 'notexist'); |
|
44 | 44 | } |
45 | 45 | } |
@@ -16,22 +16,22 @@ discard block |
||
16 | 16 | |
17 | 17 | protected function setUp() |
18 | 18 | { |
19 | - $this->object = new \Aimeos\Controller\Frontend\Product\Standard( \TestHelperFrontend::getContext() ); |
|
19 | + $this->object = new \Aimeos\Controller\Frontend\Product\Standard(\TestHelperFrontend::getContext()); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
23 | 23 | protected function tearDown() |
24 | 24 | { |
25 | - unset( $this->object ); |
|
25 | + unset($this->object); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
29 | 29 | public function testAggregate() |
30 | 30 | { |
31 | 31 | $filter = $this->object->createFilter(); |
32 | - $list = $this->object->aggregate( $filter, 'index.attribute.id' ); |
|
32 | + $list = $this->object->aggregate($filter, 'index.attribute.id'); |
|
33 | 33 | |
34 | - $this->assertGreaterThan( 0, count( $list ) ); |
|
34 | + $this->assertGreaterThan(0, count($list)); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
@@ -39,97 +39,97 @@ discard block |
||
39 | 39 | { |
40 | 40 | $filter = $this->object->createFilter(); |
41 | 41 | |
42 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
43 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
44 | - $this->assertEquals( 0, $filter->getSliceStart() ); |
|
45 | - $this->assertEquals( 100, $filter->getSliceSize() ); |
|
42 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
43 | + $this->assertEquals(array(), $filter->getSortations()); |
|
44 | + $this->assertEquals(0, $filter->getSliceStart()); |
|
45 | + $this->assertEquals(100, $filter->getSliceSize()); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
49 | 49 | public function testAddFilterAttribute() |
50 | 50 | { |
51 | 51 | $filter = $this->object->createFilter(); |
52 | - $filter = $this->object->addFilterAttribute( $filter, array( 0, 1 ), array(), array() ); |
|
52 | + $filter = $this->object->addFilterAttribute($filter, array(0, 1), array(), array()); |
|
53 | 53 | |
54 | 54 | $list = $filter->getConditions()->getExpressions(); |
55 | 55 | |
56 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
57 | - throw new \RuntimeException( 'Wrong expression' ); |
|
56 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
57 | + throw new \RuntimeException('Wrong expression'); |
|
58 | 58 | } |
59 | 59 | |
60 | - $this->assertEquals( 'index.attributeaggregate([0,1])', $list[0]->getName() ); |
|
61 | - $this->assertEquals( 2, $list[0]->getValue() ); |
|
60 | + $this->assertEquals('index.attributeaggregate([0,1])', $list[0]->getName()); |
|
61 | + $this->assertEquals(2, $list[0]->getValue()); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | |
65 | 65 | public function testAddFilterAttributeOptions() |
66 | 66 | { |
67 | 67 | $filter = $this->object->createFilter(); |
68 | - $filter = $this->object->addFilterAttribute( $filter, array(), array( 1 ), array() ); |
|
68 | + $filter = $this->object->addFilterAttribute($filter, array(), array(1), array()); |
|
69 | 69 | |
70 | 70 | $list = $filter->getConditions()->getExpressions(); |
71 | 71 | |
72 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
73 | - throw new \RuntimeException( 'Wrong expression' ); |
|
72 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
73 | + throw new \RuntimeException('Wrong expression'); |
|
74 | 74 | } |
75 | 75 | |
76 | - $this->assertEquals( 'index.attributeaggregate([1])', $list[0]->getName() ); |
|
77 | - $this->assertEquals( 0, $list[0]->getValue() ); |
|
76 | + $this->assertEquals('index.attributeaggregate([1])', $list[0]->getName()); |
|
77 | + $this->assertEquals(0, $list[0]->getValue()); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | |
81 | 81 | public function testAddFilterAttributeOne() |
82 | 82 | { |
83 | 83 | $filter = $this->object->createFilter(); |
84 | - $filter = $this->object->addFilterAttribute( $filter, array(), array(), array( 'test' => array( 2 ) ) ); |
|
84 | + $filter = $this->object->addFilterAttribute($filter, array(), array(), array('test' => array(2))); |
|
85 | 85 | |
86 | 86 | $list = $filter->getConditions()->getExpressions(); |
87 | 87 | |
88 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
89 | - throw new \RuntimeException( 'Wrong expression' ); |
|
88 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
89 | + throw new \RuntimeException('Wrong expression'); |
|
90 | 90 | } |
91 | 91 | |
92 | - $this->assertEquals( 'index.attributeaggregate([2])', $list[0]->getName() ); |
|
93 | - $this->assertEquals( 0, $list[0]->getValue() ); |
|
92 | + $this->assertEquals('index.attributeaggregate([2])', $list[0]->getName()); |
|
93 | + $this->assertEquals(0, $list[0]->getValue()); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | |
97 | 97 | public function testAddFilterCategory() |
98 | 98 | { |
99 | 99 | $filter = $this->object->createFilter(); |
100 | - $filter = $this->object->addFilterCategory( $filter, 0 ); |
|
100 | + $filter = $this->object->addFilterCategory($filter, 0); |
|
101 | 101 | |
102 | 102 | $list = $filter->getConditions()->getExpressions(); |
103 | 103 | |
104 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
105 | - throw new \RuntimeException( 'Wrong expression' ); |
|
104 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
105 | + throw new \RuntimeException('Wrong expression'); |
|
106 | 106 | } |
107 | 107 | |
108 | - $this->assertEquals( 'index.catalog.id', $list[0]->getName() ); |
|
109 | - $this->assertEquals( array( 0 ), $list[0]->getValue() ); |
|
110 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
108 | + $this->assertEquals('index.catalog.id', $list[0]->getName()); |
|
109 | + $this->assertEquals(array(0), $list[0]->getValue()); |
|
110 | + $this->assertEquals(array(), $filter->getSortations()); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | |
114 | 114 | public function testAddFilterText() |
115 | 115 | { |
116 | 116 | $filter = $this->object->createFilter(); |
117 | - $filter = $this->object->addFilterText( $filter, 'Espresso' ); |
|
117 | + $filter = $this->object->addFilterText($filter, 'Espresso'); |
|
118 | 118 | |
119 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
119 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
120 | 120 | |
121 | 121 | $list = $filter->getConditions()->getExpressions(); |
122 | 122 | |
123 | 123 | |
124 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
125 | - throw new \RuntimeException( 'Wrong expression' ); |
|
124 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
125 | + throw new \RuntimeException('Wrong expression'); |
|
126 | 126 | } |
127 | - $this->assertEquals( 'index.text.relevance("default","de","Espresso")', $list[0]->getName() ); |
|
128 | - $this->assertEquals( 0, $list[0]->getValue() ); |
|
127 | + $this->assertEquals('index.text.relevance("default","de","Espresso")', $list[0]->getName()); |
|
128 | + $this->assertEquals(0, $list[0]->getValue()); |
|
129 | 129 | |
130 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
131 | - $this->assertEquals( 0, $filter->getSliceStart() ); |
|
132 | - $this->assertEquals( 100, $filter->getSliceSize() ); |
|
130 | + $this->assertEquals(array(), $filter->getSortations()); |
|
131 | + $this->assertEquals(0, $filter->getSliceStart()); |
|
132 | + $this->assertEquals(100, $filter->getSliceSize()); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | |
@@ -138,160 +138,160 @@ discard block |
||
138 | 138 | $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE; |
139 | 139 | |
140 | 140 | $filter = $this->object->createFilter(); |
141 | - $filter = $this->object->addFilterCategory( $filter, 0, $level, 'relevance', '-', 'test' ); |
|
141 | + $filter = $this->object->addFilterCategory($filter, 0, $level, 'relevance', '-', 'test'); |
|
142 | 142 | |
143 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
143 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
144 | 144 | |
145 | 145 | $sort = $filter->getSortations(); |
146 | - if( ( $item = reset( $sort ) ) === false ) { |
|
147 | - throw new \RuntimeException( 'Sortation not set' ); |
|
146 | + if (($item = reset($sort)) === false) { |
|
147 | + throw new \RuntimeException('Sortation not set'); |
|
148 | 148 | } |
149 | 149 | |
150 | - $this->assertEquals( 'sort:index.catalog.position("test",["0"])', $item->getName() ); |
|
151 | - $this->assertEquals( '-', $item->getOperator() ); |
|
150 | + $this->assertEquals('sort:index.catalog.position("test",["0"])', $item->getName()); |
|
151 | + $this->assertEquals('-', $item->getOperator()); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | |
155 | 155 | public function testCreateFilterSortRelevanceText() |
156 | 156 | { |
157 | - $filter = $this->object->createFilter( 'relevance', '-', 1, 2, 'test' ); |
|
158 | - $filter = $this->object->addFilterText( $filter, 'Espresso' ); |
|
157 | + $filter = $this->object->createFilter('relevance', '-', 1, 2, 'test'); |
|
158 | + $filter = $this->object->addFilterText($filter, 'Espresso'); |
|
159 | 159 | |
160 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
161 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
162 | - $this->assertEquals( 1, $filter->getSliceStart() ); |
|
163 | - $this->assertEquals( 2, $filter->getSliceSize() ); |
|
160 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
161 | + $this->assertEquals(array(), $filter->getSortations()); |
|
162 | + $this->assertEquals(1, $filter->getSliceStart()); |
|
163 | + $this->assertEquals(2, $filter->getSliceSize()); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
167 | 167 | public function testCreateFilterSortCode() |
168 | 168 | { |
169 | - $filter = $this->object->createFilter( 'code' ); |
|
169 | + $filter = $this->object->createFilter('code'); |
|
170 | 170 | |
171 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
171 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
172 | 172 | |
173 | 173 | $sort = $filter->getSortations(); |
174 | - if( ( $item = reset( $sort ) ) === false ) { |
|
175 | - throw new \RuntimeException( 'Sortation not set' ); |
|
174 | + if (($item = reset($sort)) === false) { |
|
175 | + throw new \RuntimeException('Sortation not set'); |
|
176 | 176 | } |
177 | 177 | |
178 | - $this->assertEquals( 'product.code', $item->getName() ); |
|
178 | + $this->assertEquals('product.code', $item->getName()); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | |
182 | 182 | public function testCreateFilterSortName() |
183 | 183 | { |
184 | - $filter = $this->object->createFilter( 'name' ); |
|
184 | + $filter = $this->object->createFilter('name'); |
|
185 | 185 | |
186 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
186 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
187 | 187 | |
188 | 188 | $sort = $filter->getSortations(); |
189 | - if( ( $item = reset( $sort ) ) === false ) { |
|
190 | - throw new \RuntimeException( 'Sortation not set' ); |
|
189 | + if (($item = reset($sort)) === false) { |
|
190 | + throw new \RuntimeException('Sortation not set'); |
|
191 | 191 | } |
192 | 192 | |
193 | - $this->assertEquals( 'sort:index.text.value("default","de","name")', $item->getName() ); |
|
193 | + $this->assertEquals('sort:index.text.value("default","de","name")', $item->getName()); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | |
197 | 197 | public function testCreateFilterSortPrice() |
198 | 198 | { |
199 | - $filter = $this->object->createFilter( 'price' ); |
|
199 | + $filter = $this->object->createFilter('price'); |
|
200 | 200 | |
201 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
201 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
202 | 202 | |
203 | 203 | $sort = $filter->getSortations(); |
204 | - if( ( $item = reset( $sort ) ) === false ) { |
|
205 | - throw new \RuntimeException( 'Sortation not set' ); |
|
204 | + if (($item = reset($sort)) === false) { |
|
205 | + throw new \RuntimeException('Sortation not set'); |
|
206 | 206 | } |
207 | 207 | |
208 | - $this->assertStringStartsWith( 'sort:index.price.value("default","EUR","default")', $item->getName() ); |
|
208 | + $this->assertStringStartsWith('sort:index.price.value("default","EUR","default")', $item->getName()); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
212 | 212 | public function testCreateFilterSortInvalid() |
213 | 213 | { |
214 | - $filter = $this->object->createFilter( '', 'failure' ); |
|
214 | + $filter = $this->object->createFilter('', 'failure'); |
|
215 | 215 | |
216 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
217 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
216 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
217 | + $this->assertEquals(array(), $filter->getSortations()); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | |
221 | 221 | public function testGetItem() |
222 | 222 | { |
223 | 223 | $context = \TestHelperFrontend::getContext(); |
224 | - $id = \Aimeos\MShop\Factory::createManager( $context, 'product' )->findItem( 'CNC' )->getId(); |
|
224 | + $id = \Aimeos\MShop\Factory::createManager($context, 'product')->findItem('CNC')->getId(); |
|
225 | 225 | |
226 | - $result = $this->object->getItem( $id ); |
|
226 | + $result = $this->object->getItem($id); |
|
227 | 227 | |
228 | - $this->assertInstanceOf( '\Aimeos\MShop\Product\Item\Iface', $result ); |
|
229 | - $this->assertGreaterThan( 0, $result->getPropertyItems() ); |
|
230 | - $this->assertGreaterThan( 0, $result->getRefItems( 'attribute' ) ); |
|
231 | - $this->assertGreaterThan( 0, $result->getRefItems( 'media' ) ); |
|
232 | - $this->assertGreaterThan( 0, $result->getRefItems( 'price' ) ); |
|
233 | - $this->assertGreaterThan( 0, $result->getRefItems( 'product' ) ); |
|
234 | - $this->assertGreaterThan( 0, $result->getRefItems( 'text' ) ); |
|
228 | + $this->assertInstanceOf('\Aimeos\MShop\Product\Item\Iface', $result); |
|
229 | + $this->assertGreaterThan(0, $result->getPropertyItems()); |
|
230 | + $this->assertGreaterThan(0, $result->getRefItems('attribute')); |
|
231 | + $this->assertGreaterThan(0, $result->getRefItems('media')); |
|
232 | + $this->assertGreaterThan(0, $result->getRefItems('price')); |
|
233 | + $this->assertGreaterThan(0, $result->getRefItems('product')); |
|
234 | + $this->assertGreaterThan(0, $result->getRefItems('text')); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | |
238 | 238 | public function testGetItems() |
239 | 239 | { |
240 | 240 | $context = \TestHelperFrontend::getContext(); |
241 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
241 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
242 | 242 | |
243 | 243 | $search = $manager->createSearch(); |
244 | - $search->setConditions( $search->compare( '==', 'product.code', array( 'CNC', 'CNE' ) ) ); |
|
244 | + $search->setConditions($search->compare('==', 'product.code', array('CNC', 'CNE'))); |
|
245 | 245 | |
246 | 246 | $ids = array(); |
247 | - foreach( $manager->searchItems( $search ) as $productItem ) { |
|
247 | + foreach ($manager->searchItems($search) as $productItem) { |
|
248 | 248 | $ids[] = $productItem->getId(); |
249 | 249 | } |
250 | 250 | |
251 | 251 | |
252 | - $result = $this->object->getItems( $ids ); |
|
252 | + $result = $this->object->getItems($ids); |
|
253 | 253 | |
254 | - $this->assertEquals( 2, count( $result ) ); |
|
254 | + $this->assertEquals(2, count($result)); |
|
255 | 255 | |
256 | - foreach( $result as $productItem ) { |
|
257 | - $this->assertInstanceOf( '\Aimeos\MShop\Product\Item\Iface', $productItem ); |
|
256 | + foreach ($result as $productItem) { |
|
257 | + $this->assertInstanceOf('\Aimeos\MShop\Product\Item\Iface', $productItem); |
|
258 | 258 | } |
259 | 259 | } |
260 | 260 | |
261 | 261 | |
262 | 262 | public function testSearchItemsCategory() |
263 | 263 | { |
264 | - $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
264 | + $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
265 | 265 | $search = $catalogManager->createSearch(); |
266 | 266 | |
267 | - $search->setConditions( $search->compare( '==', 'catalog.code', 'new' ) ); |
|
268 | - $search->setSlice( 0, 1 ); |
|
269 | - $items = $catalogManager->searchItems( $search ); |
|
267 | + $search->setConditions($search->compare('==', 'catalog.code', 'new')); |
|
268 | + $search->setSlice(0, 1); |
|
269 | + $items = $catalogManager->searchItems($search); |
|
270 | 270 | |
271 | - if( ( $item = reset( $items ) ) === false ) { |
|
272 | - throw new \RuntimeException( 'Product item not found' ); |
|
271 | + if (($item = reset($items)) === false) { |
|
272 | + throw new \RuntimeException('Product item not found'); |
|
273 | 273 | } |
274 | 274 | |
275 | - $filter = $this->object->createFilter( 'position', '+', 1, 1 ); |
|
276 | - $filter = $this->object->addFilterCategory( $filter, $item->getId() ); |
|
275 | + $filter = $this->object->createFilter('position', '+', 1, 1); |
|
276 | + $filter = $this->object->addFilterCategory($filter, $item->getId()); |
|
277 | 277 | |
278 | 278 | $total = 0; |
279 | - $results = $this->object->searchItems( $filter, array(), $total ); |
|
279 | + $results = $this->object->searchItems($filter, array(), $total); |
|
280 | 280 | |
281 | - $this->assertEquals( 3, $total ); |
|
282 | - $this->assertEquals( 1, count( $results ) ); |
|
281 | + $this->assertEquals(3, $total); |
|
282 | + $this->assertEquals(1, count($results)); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | |
286 | 286 | public function testSearchItemsText() |
287 | 287 | { |
288 | - $filter = $this->object->createFilter( 'relevance', '+', 0, 1, 'unittype13' ); |
|
289 | - $filter = $this->object->addFilterText( $filter, 'Expresso', 'relevance', '+', 'unittype13' ); |
|
288 | + $filter = $this->object->createFilter('relevance', '+', 0, 1, 'unittype13'); |
|
289 | + $filter = $this->object->addFilterText($filter, 'Expresso', 'relevance', '+', 'unittype13'); |
|
290 | 290 | |
291 | 291 | $total = 0; |
292 | - $results = $this->object->searchItems( $filter, array(), $total ); |
|
292 | + $results = $this->object->searchItems($filter, array(), $total); |
|
293 | 293 | |
294 | - $this->assertEquals( 2, $total ); |
|
295 | - $this->assertEquals( 1, count( $results ) ); |
|
294 | + $this->assertEquals(2, $total); |
|
295 | + $this->assertEquals(1, count($results)); |
|
296 | 296 | } |
297 | 297 | } |