@@ -31,36 +31,36 @@ 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( ( $attrIds = $this->validateIds( $attrIds ) ) !== [] ) |
|
36 | + if (($attrIds = $this->validateIds($attrIds)) !== []) |
|
37 | 37 | { |
38 | - $func = $filter->createFunction( 'index.attribute:all', [$attrIds] ); |
|
38 | + $func = $filter->createFunction('index.attribute:all', [$attrIds]); |
|
39 | 39 | $expr = array( |
40 | - $filter->compare( '!=', $func, null ), |
|
40 | + $filter->compare('!=', $func, null), |
|
41 | 41 | $filter->getConditions(), |
42 | 42 | ); |
43 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
43 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
44 | 44 | } |
45 | 45 | |
46 | - if( ( $optIds = $this->validateIds( $optIds ) ) !== [] ) |
|
46 | + if (($optIds = $this->validateIds($optIds)) !== []) |
|
47 | 47 | { |
48 | 48 | $expr = array( |
49 | - $filter->compare( '==', 'index.attribute.id', $optIds ), |
|
49 | + $filter->compare('==', 'index.attribute.id', $optIds), |
|
50 | 50 | $filter->getConditions(), |
51 | 51 | ); |
52 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
52 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
53 | 53 | } |
54 | 54 | |
55 | - foreach( $oneIds as $type => $list ) |
|
55 | + foreach ($oneIds as $type => $list) |
|
56 | 56 | { |
57 | - if( ( $list = $this->validateIds( (array) $list ) ) !== [] ) |
|
57 | + if (($list = $this->validateIds((array) $list)) !== []) |
|
58 | 58 | { |
59 | 59 | $expr = array( |
60 | - $filter->compare( '==', 'index.attribute.id', $list ), |
|
60 | + $filter->compare('==', 'index.attribute.id', $list), |
|
61 | 61 | $filter->getConditions(), |
62 | 62 | ); |
63 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
63 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
@@ -80,38 +80,38 @@ discard block |
||
80 | 80 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
81 | 81 | * @since 2017.03 |
82 | 82 | */ |
83 | - public function addFilterCategory( \Aimeos\MW\Criteria\Iface $filter, $catId, |
|
84 | - $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default' ) |
|
83 | + public function addFilterCategory(\Aimeos\MW\Criteria\Iface $filter, $catId, |
|
84 | + $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default') |
|
85 | 85 | { |
86 | - $catIds = ( !is_array( $catId ) ? explode( ',', $catId ) : $catId ); |
|
86 | + $catIds = (!is_array($catId) ? explode(',', $catId) : $catId); |
|
87 | 87 | |
88 | - if( $level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ) |
|
88 | + if ($level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE) |
|
89 | 89 | { |
90 | 90 | $list = []; |
91 | - $cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'catalog' ); |
|
91 | + $cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'catalog'); |
|
92 | 92 | |
93 | - foreach( $catIds as $catId ) |
|
93 | + foreach ($catIds as $catId) |
|
94 | 94 | { |
95 | - $tree = $cntl->getTree( $catId, [], $level ); |
|
96 | - $list = array_merge( $list, $this->getCatalogIdsFromTree( $tree ) ); |
|
95 | + $tree = $cntl->getTree($catId, [], $level); |
|
96 | + $list = array_merge($list, $this->getCatalogIdsFromTree($tree)); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | $catIds = $list; |
100 | 100 | } |
101 | 101 | |
102 | - $expr = array( $filter->compare( '==', 'index.catalog.id', array_unique( $catIds ) ) ); |
|
102 | + $expr = array($filter->compare('==', 'index.catalog.id', array_unique($catIds))); |
|
103 | 103 | $expr[] = $filter->getConditions(); |
104 | 104 | |
105 | - if( $sort === 'relevance' ) |
|
105 | + if ($sort === 'relevance') |
|
106 | 106 | { |
107 | - $cmpfunc = $filter->createFunction( 'index.catalog:position', array( $listtype, $catIds ) ); |
|
108 | - $expr[] = $filter->compare( '>=', $cmpfunc, 0 ); |
|
107 | + $cmpfunc = $filter->createFunction('index.catalog:position', array($listtype, $catIds)); |
|
108 | + $expr[] = $filter->compare('>=', $cmpfunc, 0); |
|
109 | 109 | |
110 | - $sortfunc = $filter->createFunction( 'sort:index.catalog:position', array( $listtype, $catIds ) ); |
|
111 | - $filter->setSortations( [$filter->sort( $direction, $sortfunc ), $filter->sort( '+', 'product.id' )] ); |
|
110 | + $sortfunc = $filter->createFunction('sort:index.catalog:position', array($listtype, $catIds)); |
|
111 | + $filter->setSortations([$filter->sort($direction, $sortfunc), $filter->sort('+', 'product.id')]); |
|
112 | 112 | } |
113 | 113 | |
114 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
114 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
115 | 115 | |
116 | 116 | return $filter; |
117 | 117 | } |
@@ -125,16 +125,16 @@ discard block |
||
125 | 125 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
126 | 126 | * @since 2018.07 |
127 | 127 | */ |
128 | - public function addFilterSupplier( \Aimeos\MW\Criteria\Iface $filter, array $supIds ) |
|
128 | + public function addFilterSupplier(\Aimeos\MW\Criteria\Iface $filter, array $supIds) |
|
129 | 129 | { |
130 | - if( !empty( $supIds ) ) |
|
130 | + if (!empty($supIds)) |
|
131 | 131 | { |
132 | - $supIds = $this->validateIds( $supIds ); |
|
132 | + $supIds = $this->validateIds($supIds); |
|
133 | 133 | $expr = array( |
134 | - $filter->compare( '==', 'index.supplier.id', $supIds ), |
|
134 | + $filter->compare('==', 'index.supplier.id', $supIds), |
|
135 | 135 | $filter->getConditions(), |
136 | 136 | ); |
137 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
137 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | return $filter; |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
153 | 153 | * @since 2017.03 |
154 | 154 | */ |
155 | - public function addFilterText( \Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default' ) |
|
155 | + public function addFilterText(\Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default') |
|
156 | 156 | { |
157 | 157 | $langid = $this->getContext()->getLocale()->getLanguageId(); |
158 | - $cmpfunc = $filter->createFunction( 'index.text:relevance', array( $listtype, $langid, $input ) ); |
|
159 | - $expr = array( $filter->compare( '>', $cmpfunc, 0 ), $filter->getConditions() ); |
|
158 | + $cmpfunc = $filter->createFunction('index.text:relevance', array($listtype, $langid, $input)); |
|
159 | + $expr = array($filter->compare('>', $cmpfunc, 0), $filter->getConditions()); |
|
160 | 160 | |
161 | - return $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
161 | + return $filter->setConditions($filter->combine('&&', $expr)); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | * @return array Associative list of key values as key and the product count for this key as value |
171 | 171 | * @since 2017.03 |
172 | 172 | */ |
173 | - public function aggregate( \Aimeos\MW\Criteria\Iface $filter, $key ) |
|
173 | + public function aggregate(\Aimeos\MW\Criteria\Iface $filter, $key) |
|
174 | 174 | { |
175 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->aggregate( $filter, $key ); |
|
175 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->aggregate($filter, $key); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
188 | 188 | * @since 2017.03 |
189 | 189 | */ |
190 | - public function createFilter( $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' ) |
|
190 | + public function createFilter($sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default') |
|
191 | 191 | { |
192 | 192 | $sortations = []; |
193 | 193 | $context = $this->getContext(); |
194 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'index' ); |
|
194 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'index'); |
|
195 | 195 | |
196 | 196 | |
197 | 197 | /** controller/frontend/product/ignore-dates |
@@ -206,55 +206,55 @@ discard block |
||
206 | 206 | * @since 2017.10 |
207 | 207 | * @category Developer |
208 | 208 | */ |
209 | - if( $context->getConfig()->get( 'controller/frontend/product/ignore-dates', false ) ) |
|
209 | + if ($context->getConfig()->get('controller/frontend/product/ignore-dates', false)) |
|
210 | 210 | { |
211 | 211 | $search = $manager->createSearch(); |
212 | - $search->setConditions( $search->compare( '>', 'product.status', 0 ) ); |
|
212 | + $search->setConditions($search->compare('>', 'product.status', 0)); |
|
213 | 213 | } |
214 | 214 | else |
215 | 215 | { |
216 | - $search = $manager->createSearch( true ); |
|
216 | + $search = $manager->createSearch(true); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
220 | - $expr = array( $search->compare( '!=', 'index.catalog.id', null ) ); |
|
220 | + $expr = array($search->compare('!=', 'index.catalog.id', null)); |
|
221 | 221 | |
222 | - switch( $sort ) |
|
222 | + switch ($sort) |
|
223 | 223 | { |
224 | 224 | case 'code': |
225 | - $sortations[] = $search->sort( $direction, 'product.code' ); |
|
225 | + $sortations[] = $search->sort($direction, 'product.code'); |
|
226 | 226 | break; |
227 | 227 | |
228 | 228 | case 'ctime': |
229 | - $sortations[] = $search->sort( $direction, 'product.ctime' ); |
|
229 | + $sortations[] = $search->sort($direction, 'product.ctime'); |
|
230 | 230 | break; |
231 | 231 | |
232 | 232 | case 'name': |
233 | 233 | $langid = $context->getLocale()->getLanguageId(); |
234 | 234 | |
235 | - $cmpfunc = $search->createFunction( 'index.text:name', [$langid] ); |
|
236 | - $expr[] = $search->compare( '!=', $cmpfunc, null ); |
|
235 | + $cmpfunc = $search->createFunction('index.text:name', [$langid]); |
|
236 | + $expr[] = $search->compare('!=', $cmpfunc, null); |
|
237 | 237 | |
238 | - $sortfunc = $search->createFunction( 'sort:index.text:name', [$langid] ); |
|
239 | - $sortations[] = $search->sort( $direction, $sortfunc ); |
|
238 | + $sortfunc = $search->createFunction('sort:index.text:name', [$langid]); |
|
239 | + $sortations[] = $search->sort($direction, $sortfunc); |
|
240 | 240 | break; |
241 | 241 | |
242 | 242 | case 'price': |
243 | 243 | $currencyid = $context->getLocale()->getCurrencyId(); |
244 | 244 | |
245 | - $cmpfunc = $search->createFunction( 'index.price:value', array( $listtype, $currencyid, 'default' ) ); |
|
246 | - $expr[] = $search->compare( '!=', $cmpfunc, null ); |
|
245 | + $cmpfunc = $search->createFunction('index.price:value', array($listtype, $currencyid, 'default')); |
|
246 | + $expr[] = $search->compare('!=', $cmpfunc, null); |
|
247 | 247 | |
248 | - $sortfunc = $search->createFunction( 'sort:index.price:value', array( $listtype, $currencyid, 'default' ) ); |
|
249 | - $sortations[] = $search->sort( $direction, $sortfunc ); |
|
248 | + $sortfunc = $search->createFunction('sort:index.price:value', array($listtype, $currencyid, 'default')); |
|
249 | + $sortations[] = $search->sort($direction, $sortfunc); |
|
250 | 250 | break; |
251 | 251 | } |
252 | 252 | |
253 | 253 | $expr[] = $search->getConditions(); |
254 | 254 | |
255 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
256 | - $search->setSortations( $sortations ); |
|
257 | - $search->setSlice( $start, $size ); |
|
255 | + $search->setConditions($search->combine('&&', $expr)); |
|
256 | + $search->setSortations($sortations); |
|
257 | + $search->setSlice($start, $size); |
|
258 | 258 | |
259 | 259 | return $search; |
260 | 260 | } |
@@ -268,15 +268,15 @@ discard block |
||
268 | 268 | * @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items |
269 | 269 | * @since 2017.03 |
270 | 270 | */ |
271 | - public function getItem( $productId, array $domains = array( 'attribute', 'media', 'price', 'product', 'product/property', 'text' ) ) |
|
271 | + public function getItem($productId, array $domains = array('attribute', 'media', 'price', 'product', 'product/property', 'text')) |
|
272 | 272 | { |
273 | - $items = $this->getItems( [$productId], $domains ); |
|
273 | + $items = $this->getItems([$productId], $domains); |
|
274 | 274 | |
275 | - if( ( $item = reset( $items ) ) !== false ) { |
|
275 | + if (($item = reset($items)) !== false) { |
|
276 | 276 | return $item; |
277 | 277 | } |
278 | 278 | |
279 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Product item with ID "%1$s" not found', $productId ) ); |
|
279 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Product item with ID "%1$s" not found', $productId)); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | |
@@ -288,10 +288,10 @@ discard block |
||
288 | 288 | * @return \Aimeos\MShop\Product\Item\Iface[] Associative list of product IDs as keys and product items as values |
289 | 289 | * @since 2017.03 |
290 | 290 | */ |
291 | - public function getItems( array $productIds, array $domains = array( 'media', 'price', 'text' ) ) |
|
291 | + public function getItems(array $productIds, array $domains = array('media', 'price', 'text')) |
|
292 | 292 | { |
293 | 293 | $context = $this->getContext(); |
294 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
294 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
295 | 295 | |
296 | 296 | /** controller/frontend/order/ignore-dates |
297 | 297 | * Ignore start and end dates of products |
@@ -305,24 +305,24 @@ discard block |
||
305 | 305 | * @since 2017.08 |
306 | 306 | * @category Developer |
307 | 307 | */ |
308 | - if( $context->getConfig()->get( 'controller/frontend/product/ignore-dates', false ) ) |
|
308 | + if ($context->getConfig()->get('controller/frontend/product/ignore-dates', false)) |
|
309 | 309 | { |
310 | 310 | $search = $manager->createSearch(); |
311 | - $search->setConditions( $search->compare( '>', 'product.status', 0 ) ); |
|
311 | + $search->setConditions($search->compare('>', 'product.status', 0)); |
|
312 | 312 | } |
313 | 313 | else |
314 | 314 | { |
315 | - $search = $manager->createSearch( true ); |
|
315 | + $search = $manager->createSearch(true); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | $expr = array( |
319 | - $search->compare( '==', 'product.id', $productIds ), |
|
319 | + $search->compare('==', 'product.id', $productIds), |
|
320 | 320 | $search->getConditions(), |
321 | 321 | ); |
322 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
323 | - $search->setSlice( 0, count( $productIds ) ); |
|
322 | + $search->setConditions($search->combine('&&', $expr)); |
|
323 | + $search->setSlice(0, count($productIds)); |
|
324 | 324 | |
325 | - return $manager->searchItems( $search, $domains ); |
|
325 | + return $manager->searchItems($search, $domains); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | |
@@ -335,9 +335,9 @@ discard block |
||
335 | 335 | * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface |
336 | 336 | * @since 2017.03 |
337 | 337 | */ |
338 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null ) |
|
338 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null) |
|
339 | 339 | { |
340 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->searchItems( $filter, $domains, $total ); |
|
340 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->searchItems($filter, $domains, $total); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | |
@@ -347,16 +347,16 @@ discard block |
||
347 | 347 | * @param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item with children |
348 | 348 | * @return array List of catalog IDs |
349 | 349 | */ |
350 | - protected function getCatalogIdsFromTree( \Aimeos\MShop\Catalog\Item\Iface $item ) |
|
350 | + protected function getCatalogIdsFromTree(\Aimeos\MShop\Catalog\Item\Iface $item) |
|
351 | 351 | { |
352 | - if( $item->getStatus() < 1 ) { |
|
352 | + if ($item->getStatus() < 1) { |
|
353 | 353 | return []; |
354 | 354 | } |
355 | 355 | |
356 | - $list = [ $item->getId() ]; |
|
356 | + $list = [$item->getId()]; |
|
357 | 357 | |
358 | - foreach( $item->getChildren() as $child ) { |
|
359 | - $list = array_merge( $list, $this->getCatalogIdsFromTree( $child ) ); |
|
358 | + foreach ($item->getChildren() as $child) { |
|
359 | + $list = array_merge($list, $this->getCatalogIdsFromTree($child)); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | return $list; |
@@ -369,13 +369,13 @@ discard block |
||
369 | 369 | * @param array $ids List of IDs to validate |
370 | 370 | * @return array List of validated IDs |
371 | 371 | */ |
372 | - protected function validateIds( array $ids ) |
|
372 | + protected function validateIds(array $ids) |
|
373 | 373 | { |
374 | 374 | $list = []; |
375 | 375 | |
376 | - foreach( $ids as $id ) |
|
376 | + foreach ($ids as $id) |
|
377 | 377 | { |
378 | - if( $id != '' ) { |
|
378 | + if ($id != '') { |
|
379 | 379 | $list[] = (int) $id; |
380 | 380 | } |
381 | 381 | } |
@@ -31,52 +31,52 @@ 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( $context, 'product' ); |
|
41 | - $prices = $manager->getItem( $product->getProductId(), array( 'price' ) )->getRefItems( 'price', 'default' ); |
|
40 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
41 | + $prices = $manager->getItem($product->getProductId(), array('price'))->getRefItems('price', 'default'); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
46 | - $price = $priceManager->getLowestPrice( $prices, $quantity ); |
|
45 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
46 | + $price = $priceManager->getLowestPrice($prices, $quantity); |
|
47 | 47 | |
48 | 48 | // customers can pay what they would like to pay |
49 | - if( ( $attr = $product->getAttributeItem( 'price', 'custom' ) ) !== null ) |
|
49 | + if (($attr = $product->getAttributeItem('price', 'custom')) !== null) |
|
50 | 50 | { |
51 | 51 | $amount = $attr->getValue(); |
52 | 52 | |
53 | - if( preg_match( '/^[0-9]*(\.[0-9]+)?$/', $amount ) !== 1 || ((double) $amount) < 0.01 ) |
|
53 | + if (preg_match('/^[0-9]*(\.[0-9]+)?$/', $amount) !== 1 || ((double) $amount) < 0.01) |
|
54 | 54 | { |
55 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Invalid price value "%1$s"' ); |
|
56 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $amount ) ); |
|
55 | + $msg = $context->getI18n()->dt('controller/frontend', 'Invalid price value "%1$s"'); |
|
56 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $amount)); |
|
57 | 57 | } |
58 | 58 | |
59 | - $price->setValue( $amount ); |
|
59 | + $price->setValue($amount); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | $orderAttributes = $product->getAttributes(); |
63 | - $attrItems = $this->getAttributeItems( $orderAttributes ); |
|
63 | + $attrItems = $this->getAttributeItems($orderAttributes); |
|
64 | 64 | |
65 | 65 | // add prices of (optional) attributes |
66 | - foreach( $orderAttributes as $orderAttrItem ) |
|
66 | + foreach ($orderAttributes as $orderAttrItem) |
|
67 | 67 | { |
68 | 68 | $attrId = $orderAttrItem->getAttributeId(); |
69 | 69 | |
70 | - if( isset( $attrItems[$attrId] ) |
|
71 | - && ( $prices = $attrItems[$attrId]->getRefItems( 'price', 'default' ) ) !== [] |
|
70 | + if (isset($attrItems[$attrId]) |
|
71 | + && ($prices = $attrItems[$attrId]->getRefItems('price', 'default')) !== [] |
|
72 | 72 | ) { |
73 | - $attrPrice = $priceManager->getLowestPrice( $prices, $orderAttrItem->getQuantity() ); |
|
74 | - $price->addItem( $attrPrice, $orderAttrItem->getQuantity() ); |
|
73 | + $attrPrice = $priceManager->getLowestPrice($prices, $orderAttrItem->getQuantity()); |
|
74 | + $price->addItem($attrPrice, $orderAttrItem->getQuantity()); |
|
75 | 75 | } |
76 | 76 | } |
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 | 81 | return $price; |
82 | 82 | } |
@@ -90,36 +90,36 @@ discard block |
||
90 | 90 | * @param array $refMap Associative list of list type codes as keys and lists of reference IDs as values |
91 | 91 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated |
92 | 92 | */ |
93 | - protected function checkListRef( $prodId, $domain, array $refMap ) |
|
93 | + protected function checkListRef($prodId, $domain, array $refMap) |
|
94 | 94 | { |
95 | - if( empty( $refMap ) ) { |
|
95 | + if (empty($refMap)) { |
|
96 | 96 | return; |
97 | 97 | } |
98 | 98 | |
99 | 99 | $context = $this->getContext(); |
100 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
101 | - $search = $productManager->createSearch( true ); |
|
100 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
101 | + $search = $productManager->createSearch(true); |
|
102 | 102 | |
103 | 103 | $expr = array( |
104 | - $search->compare( '==', 'product.id', $prodId ), |
|
104 | + $search->compare('==', 'product.id', $prodId), |
|
105 | 105 | $search->getConditions(), |
106 | 106 | ); |
107 | 107 | |
108 | - foreach( $refMap as $listType => $refIds ) |
|
108 | + foreach ($refMap as $listType => $refIds) |
|
109 | 109 | { |
110 | - foreach( $refIds as $key => $refId ) |
|
110 | + foreach ($refIds as $key => $refId) |
|
111 | 111 | { |
112 | - $cmpfunc = $search->createFunction( 'product:has', [$domain, $listType, (string) $refId] ); |
|
113 | - $expr[] = $search->compare( '!=', $cmpfunc, null ); |
|
112 | + $cmpfunc = $search->createFunction('product:has', [$domain, $listType, (string) $refId]); |
|
113 | + $expr[] = $search->compare('!=', $cmpfunc, null); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
117 | + $search->setConditions($search->combine('&&', $expr)); |
|
118 | 118 | |
119 | - if( count( $productManager->searchItems( $search, [] ) ) === 0 ) |
|
119 | + if (count($productManager->searchItems($search, [])) === 0) |
|
120 | 120 | { |
121 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Invalid "%1$s" references for product with ID %2$s' ); |
|
122 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $domain, json_encode( $prodId ) ) ); |
|
121 | + $msg = $context->getI18n()->dt('controller/frontend', 'Invalid "%1$s" references for product with ID %2$s'); |
|
122 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $domain, json_encode($prodId))); |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
@@ -130,40 +130,40 @@ discard block |
||
130 | 130 | * @param \Aimeos\MShop\Locale\Item\Iface $locale Locale object from current basket |
131 | 131 | * @param string $type Basket type |
132 | 132 | */ |
133 | - protected function checkLocale( \Aimeos\MShop\Locale\Item\Iface $locale, $type ) |
|
133 | + protected function checkLocale(\Aimeos\MShop\Locale\Item\Iface $locale, $type) |
|
134 | 134 | { |
135 | 135 | $errors = []; |
136 | 136 | $context = $this->getContext(); |
137 | 137 | $session = $context->getSession(); |
138 | 138 | |
139 | - $localeStr = $session->get( 'aimeos/basket/locale' ); |
|
139 | + $localeStr = $session->get('aimeos/basket/locale'); |
|
140 | 140 | $localeKey = $locale->getSite()->getCode() . '|' . $locale->getLanguageId() . '|' . $locale->getCurrencyId(); |
141 | 141 | |
142 | - if( $localeStr !== null && $localeStr !== $localeKey ) |
|
142 | + if ($localeStr !== null && $localeStr !== $localeKey) |
|
143 | 143 | { |
144 | - $locParts = explode( '|', $localeStr ); |
|
145 | - $locSite = ( isset( $locParts[0] ) ? $locParts[0] : '' ); |
|
146 | - $locLanguage = ( isset( $locParts[1] ) ? $locParts[1] : '' ); |
|
147 | - $locCurrency = ( isset( $locParts[2] ) ? $locParts[2] : '' ); |
|
144 | + $locParts = explode('|', $localeStr); |
|
145 | + $locSite = (isset($locParts[0]) ? $locParts[0] : ''); |
|
146 | + $locLanguage = (isset($locParts[1]) ? $locParts[1] : ''); |
|
147 | + $locCurrency = (isset($locParts[2]) ? $locParts[2] : ''); |
|
148 | 148 | |
149 | - $localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' ); |
|
150 | - $locale = $localeManager->bootstrap( $locSite, $locLanguage, $locCurrency, false ); |
|
149 | + $localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale'); |
|
150 | + $locale = $localeManager->bootstrap($locSite, $locLanguage, $locCurrency, false); |
|
151 | 151 | |
152 | 152 | $context = clone $context; |
153 | - $context->setLocale( $locale ); |
|
153 | + $context->setLocale($locale); |
|
154 | 154 | |
155 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
156 | - $basket = $manager->getSession( $type ); |
|
155 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
156 | + $basket = $manager->getSession($type); |
|
157 | 157 | |
158 | - $this->copyAddresses( $basket, $errors, $localeKey ); |
|
159 | - $this->copyServices( $basket, $errors ); |
|
160 | - $this->copyProducts( $basket, $errors, $localeKey ); |
|
161 | - $this->copyCoupons( $basket, $errors, $localeKey ); |
|
158 | + $this->copyAddresses($basket, $errors, $localeKey); |
|
159 | + $this->copyServices($basket, $errors); |
|
160 | + $this->copyProducts($basket, $errors, $localeKey); |
|
161 | + $this->copyCoupons($basket, $errors, $localeKey); |
|
162 | 162 | |
163 | - $manager->setSession( $basket, $type ); |
|
163 | + $manager->setSession($basket, $type); |
|
164 | 164 | } |
165 | 165 | |
166 | - $session->set( 'aimeos/basket/locale', $localeKey ); |
|
166 | + $session->set('aimeos/basket/locale', $localeKey); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | |
@@ -175,22 +175,22 @@ discard block |
||
175 | 175 | * @param string $localeKey Unique identifier of the site, language and currency |
176 | 176 | * @return array Associative list of errors occured |
177 | 177 | */ |
178 | - protected function copyAddresses( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
178 | + protected function copyAddresses(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
179 | 179 | { |
180 | - foreach( $basket->getAddresses() as $type => $item ) |
|
180 | + foreach ($basket->getAddresses() as $type => $item) |
|
181 | 181 | { |
182 | 182 | try |
183 | 183 | { |
184 | - $this->setAddress( $type, $item->toArray() ); |
|
185 | - $basket->deleteAddress( $type ); |
|
184 | + $this->setAddress($type, $item->toArray()); |
|
185 | + $basket->deleteAddress($type); |
|
186 | 186 | } |
187 | - catch( \Exception $e ) |
|
187 | + catch (\Exception $e) |
|
188 | 188 | { |
189 | 189 | $logger = $this->getContext()->getLogger(); |
190 | 190 | $errors['address'][$type] = $e->getMessage(); |
191 | 191 | |
192 | 192 | $str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s'; |
193 | - $logger->log( sprintf( $str, $type, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
193 | + $logger->log(sprintf($str, $type, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
@@ -206,22 +206,22 @@ discard block |
||
206 | 206 | * @param string $localeKey Unique identifier of the site, language and currency |
207 | 207 | * @return array Associative list of errors occured |
208 | 208 | */ |
209 | - protected function copyCoupons( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
209 | + protected function copyCoupons(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
210 | 210 | { |
211 | - foreach( $basket->getCoupons() as $code => $list ) |
|
211 | + foreach ($basket->getCoupons() as $code => $list) |
|
212 | 212 | { |
213 | 213 | try |
214 | 214 | { |
215 | - $this->addCoupon( $code ); |
|
216 | - $basket->deleteCoupon( $code, true ); |
|
215 | + $this->addCoupon($code); |
|
216 | + $basket->deleteCoupon($code, true); |
|
217 | 217 | } |
218 | - catch( \Exception $e ) |
|
218 | + catch (\Exception $e) |
|
219 | 219 | { |
220 | 220 | $logger = $this->getContext()->getLogger(); |
221 | 221 | $errors['coupon'][$code] = $e->getMessage(); |
222 | 222 | |
223 | 223 | $str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s'; |
224 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
224 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
@@ -237,11 +237,11 @@ discard block |
||
237 | 237 | * @param string $localeKey Unique identifier of the site, language and currency |
238 | 238 | * @return array Associative list of errors occured |
239 | 239 | */ |
240 | - protected function copyProducts( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
240 | + protected function copyProducts(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
241 | 241 | { |
242 | - foreach( $basket->getProducts() as $pos => $product ) |
|
242 | + foreach ($basket->getProducts() as $pos => $product) |
|
243 | 243 | { |
244 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) { |
|
244 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) { |
|
245 | 245 | continue; |
246 | 246 | } |
247 | 247 | |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | { |
250 | 250 | $variantIds = $configIds = $customIds = []; |
251 | 251 | |
252 | - foreach( $product->getAttributeItems() as $attrItem ) |
|
252 | + foreach ($product->getAttributeItems() as $attrItem) |
|
253 | 253 | { |
254 | - switch( $attrItem->getType() ) |
|
254 | + switch ($attrItem->getType()) |
|
255 | 255 | { |
256 | 256 | case 'variant': $variantIds[] = $attrItem->getAttributeId(); break; |
257 | 257 | case 'config': $configIds[$attrItem->getAttributeId()] = $attrItem->getQuantity(); break; |
@@ -264,16 +264,16 @@ discard block |
||
264 | 264 | $variantIds, $configIds, [], $customIds |
265 | 265 | ); |
266 | 266 | |
267 | - $basket->deleteProduct( $pos ); |
|
267 | + $basket->deleteProduct($pos); |
|
268 | 268 | } |
269 | - catch( \Exception $e ) |
|
269 | + catch (\Exception $e) |
|
270 | 270 | { |
271 | 271 | $code = $product->getProductCode(); |
272 | 272 | $logger = $this->getContext()->getLogger(); |
273 | 273 | $errors['product'][$pos] = $e->getMessage(); |
274 | 274 | |
275 | 275 | $str = 'Error migrating product with code "%1$s" in basket to locale "%2$s": %3$s'; |
276 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
276 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | |
@@ -288,24 +288,24 @@ discard block |
||
288 | 288 | * @param array $errors Associative list of previous errors |
289 | 289 | * @return array Associative list of errors occured |
290 | 290 | */ |
291 | - protected function copyServices( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors ) |
|
291 | + protected function copyServices(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors) |
|
292 | 292 | { |
293 | - foreach( $basket->getServices() as $type => $list ) |
|
293 | + foreach ($basket->getServices() as $type => $list) |
|
294 | 294 | { |
295 | - foreach( $list as $item ) |
|
295 | + foreach ($list as $item) |
|
296 | 296 | { |
297 | 297 | try |
298 | 298 | { |
299 | 299 | $attributes = []; |
300 | 300 | |
301 | - foreach( $item->getAttributes() as $attrItem ) { |
|
301 | + foreach ($item->getAttributes() as $attrItem) { |
|
302 | 302 | $attributes[$attrItem->getCode()] = $attrItem->getValue(); |
303 | 303 | } |
304 | 304 | |
305 | - $this->addService( $type, $item->getServiceId(), $attributes ); |
|
306 | - $basket->deleteService( $type ); |
|
305 | + $this->addService($type, $item->getServiceId(), $attributes); |
|
306 | + $basket->deleteService($type); |
|
307 | 307 | } |
308 | - catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically |
|
308 | + catch (\Exception $e) {; } // Don't notify the user as appropriate services can be added automatically |
|
309 | 309 | } |
310 | 310 | } |
311 | 311 | |
@@ -318,28 +318,28 @@ discard block |
||
318 | 318 | * |
319 | 319 | * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object |
320 | 320 | */ |
321 | - protected function createSubscriptions( \Aimeos\MShop\Order\Item\Base\Iface $basket ) |
|
321 | + protected function createSubscriptions(\Aimeos\MShop\Order\Item\Base\Iface $basket) |
|
322 | 322 | { |
323 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'subscription' ); |
|
323 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'subscription'); |
|
324 | 324 | |
325 | - foreach( $basket->getProducts() as $orderProduct ) |
|
325 | + foreach ($basket->getProducts() as $orderProduct) |
|
326 | 326 | { |
327 | - if( ( $interval = $orderProduct->getAttribute( 'interval', 'config' ) ) !== null ) |
|
327 | + if (($interval = $orderProduct->getAttribute('interval', 'config')) !== null) |
|
328 | 328 | { |
329 | 329 | $item = $manager->createItem(); |
330 | - $item->setOrderBaseId( $basket->getId() ); |
|
331 | - $item->setOrderProductId( $orderProduct->getId() ); |
|
332 | - $item->setInterval( $interval ); |
|
333 | - $item->setStatus( 1 ); |
|
334 | - |
|
335 | - if( ( $end = $orderProduct->getAttribute( 'intervalend', 'custom' ) ) !== null |
|
336 | - || ( $end = $orderProduct->getAttribute( 'intervalend', 'config' ) ) !== null |
|
337 | - || ( $end = $orderProduct->getAttribute( 'intervalend', 'hidden' ) ) !== null |
|
330 | + $item->setOrderBaseId($basket->getId()); |
|
331 | + $item->setOrderProductId($orderProduct->getId()); |
|
332 | + $item->setInterval($interval); |
|
333 | + $item->setStatus(1); |
|
334 | + |
|
335 | + if (($end = $orderProduct->getAttribute('intervalend', 'custom')) !== null |
|
336 | + || ($end = $orderProduct->getAttribute('intervalend', 'config')) !== null |
|
337 | + || ($end = $orderProduct->getAttribute('intervalend', 'hidden')) !== null |
|
338 | 338 | ) { |
339 | - $item->setDateEnd( $end ); |
|
339 | + $item->setDateEnd($end); |
|
340 | 340 | } |
341 | 341 | |
342 | - $manager->saveItem( $item, false ); |
|
342 | + $manager->saveItem($item, false); |
|
343 | 343 | } |
344 | 344 | } |
345 | 345 | } |
@@ -353,32 +353,32 @@ discard block |
||
353 | 353 | * @return array List of items implementing \Aimeos\MShop\Attribute\Item\Iface |
354 | 354 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the actual attribute number doesn't match the expected one |
355 | 355 | */ |
356 | - protected function getAttributes( array $attributeIds, array $domains = array( 'price', 'text' ) ) |
|
356 | + protected function getAttributes(array $attributeIds, array $domains = array('price', 'text')) |
|
357 | 357 | { |
358 | - if( empty( $attributeIds ) ) { |
|
358 | + if (empty($attributeIds)) { |
|
359 | 359 | return []; |
360 | 360 | } |
361 | 361 | |
362 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
362 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
363 | 363 | |
364 | - $search = $attributeManager->createSearch( true ); |
|
364 | + $search = $attributeManager->createSearch(true); |
|
365 | 365 | $expr = array( |
366 | - $search->compare( '==', 'attribute.id', $attributeIds ), |
|
366 | + $search->compare('==', 'attribute.id', $attributeIds), |
|
367 | 367 | $search->getConditions(), |
368 | 368 | ); |
369 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
370 | - $search->setSlice( 0, 0x7fffffff ); |
|
369 | + $search->setConditions($search->combine('&&', $expr)); |
|
370 | + $search->setSlice(0, 0x7fffffff); |
|
371 | 371 | |
372 | - $attrItems = $attributeManager->searchItems( $search, $domains ); |
|
372 | + $attrItems = $attributeManager->searchItems($search, $domains); |
|
373 | 373 | |
374 | - if( count( $attrItems ) !== count( $attributeIds ) ) |
|
374 | + if (count($attrItems) !== count($attributeIds)) |
|
375 | 375 | { |
376 | 376 | $i18n = $this->getContext()->getI18n(); |
377 | - $expected = implode( ',', $attributeIds ); |
|
378 | - $actual = implode( ',', array_keys( $attrItems ) ); |
|
379 | - $msg = $i18n->dt( 'controller/frontend', 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"' ); |
|
377 | + $expected = implode(',', $attributeIds); |
|
378 | + $actual = implode(',', array_keys($attrItems)); |
|
379 | + $msg = $i18n->dt('controller/frontend', 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"'); |
|
380 | 380 | |
381 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $actual, $expected ) ); |
|
381 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $actual, $expected)); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | return $attrItems; |
@@ -391,31 +391,31 @@ discard block |
||
391 | 391 | * @param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Item[] $orderAttributes List of order product attribute items |
392 | 392 | * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as key and attribute items as values |
393 | 393 | */ |
394 | - protected function getAttributeItems( array $orderAttributes ) |
|
394 | + protected function getAttributeItems(array $orderAttributes) |
|
395 | 395 | { |
396 | - if( empty( $orderAttributes ) ) { |
|
396 | + if (empty($orderAttributes)) { |
|
397 | 397 | return []; |
398 | 398 | } |
399 | 399 | |
400 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
401 | - $search = $attributeManager->createSearch( true ); |
|
400 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
401 | + $search = $attributeManager->createSearch(true); |
|
402 | 402 | $expr = []; |
403 | 403 | |
404 | - foreach( $orderAttributes as $item ) |
|
404 | + foreach ($orderAttributes as $item) |
|
405 | 405 | { |
406 | 406 | $tmp = array( |
407 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
408 | - $search->compare( '==', 'attribute.code', $item->getValue() ), |
|
409 | - $search->compare( '==', 'attribute.type.domain', 'product' ), |
|
410 | - $search->compare( '==', 'attribute.type.code', $item->getCode() ), |
|
411 | - $search->compare( '>', 'attribute.type.status', 0 ), |
|
407 | + $search->compare('==', 'attribute.domain', 'product'), |
|
408 | + $search->compare('==', 'attribute.code', $item->getValue()), |
|
409 | + $search->compare('==', 'attribute.type.domain', 'product'), |
|
410 | + $search->compare('==', 'attribute.type.code', $item->getCode()), |
|
411 | + $search->compare('>', 'attribute.type.status', 0), |
|
412 | 412 | $search->getConditions(), |
413 | 413 | ); |
414 | - $expr[] = $search->combine( '&&', $tmp ); |
|
414 | + $expr[] = $search->combine('&&', $tmp); |
|
415 | 415 | } |
416 | 416 | |
417 | - $search->setConditions( $search->combine( '||', $expr ) ); |
|
418 | - return $attributeManager->searchItems( $search, array( 'price' ) ); |
|
417 | + $search->setConditions($search->combine('||', $expr)); |
|
418 | + return $attributeManager->searchItems($search, array('price')); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | |
@@ -428,24 +428,24 @@ discard block |
||
428 | 428 | * @param array $quantities Associative list of attribute IDs as keys and their quantities as values |
429 | 429 | * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface |
430 | 430 | */ |
431 | - protected function getOrderProductAttributes( $type, array $ids, array $values = [], array $quantities = [] ) |
|
431 | + protected function getOrderProductAttributes($type, array $ids, array $values = [], array $quantities = []) |
|
432 | 432 | { |
433 | - if( empty( $ids ) ) { |
|
433 | + if (empty($ids)) { |
|
434 | 434 | return []; |
435 | 435 | } |
436 | 436 | |
437 | 437 | $list = []; |
438 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product/attribute' ); |
|
438 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product/attribute'); |
|
439 | 439 | |
440 | - foreach( $this->getAttributes( $ids ) as $id => $attrItem ) |
|
440 | + foreach ($this->getAttributes($ids) as $id => $attrItem) |
|
441 | 441 | { |
442 | 442 | $item = $manager->createItem(); |
443 | - $item->copyFrom( $attrItem ); |
|
444 | - $item->setType( $type ); |
|
445 | - $item->setQuantity( isset( $quantities[$id] ) ? $quantities[$id] : 1 ); |
|
443 | + $item->copyFrom($attrItem); |
|
444 | + $item->setType($type); |
|
445 | + $item->setQuantity(isset($quantities[$id]) ? $quantities[$id] : 1); |
|
446 | 446 | |
447 | - if( isset( $values[$id] ) ) { |
|
448 | - $item->setValue( $values[$id] ); |
|
447 | + if (isset($values[$id])) { |
|
448 | + $item->setValue($values[$id]); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | $list[] = $item; |
@@ -462,23 +462,23 @@ discard block |
||
462 | 462 | * @param string $code Code of the list type |
463 | 463 | * @return \Aimeos\MShop\Common\Item\Type\Iface List type item |
464 | 464 | */ |
465 | - protected function getProductListTypeItem( $domain, $code ) |
|
465 | + protected function getProductListTypeItem($domain, $code) |
|
466 | 466 | { |
467 | 467 | $context = $this->getContext(); |
468 | 468 | |
469 | - if( empty( $this->listTypeItems ) ) |
|
469 | + if (empty($this->listTypeItems)) |
|
470 | 470 | { |
471 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists/type' ); |
|
471 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product/lists/type'); |
|
472 | 472 | |
473 | - foreach( $manager->searchItems( $manager->createSearch( true ) ) as $item ) { |
|
474 | - $this->listTypeItems[ $item->getDomain() ][ $item->getCode() ] = $item; |
|
473 | + foreach ($manager->searchItems($manager->createSearch(true)) as $item) { |
|
474 | + $this->listTypeItems[$item->getDomain()][$item->getCode()] = $item; |
|
475 | 475 | } |
476 | 476 | } |
477 | 477 | |
478 | - if( !isset( $this->listTypeItems[$domain][$code] ) ) |
|
478 | + if (!isset($this->listTypeItems[$domain][$code])) |
|
479 | 479 | { |
480 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'List type for domain "%1$s" and code "%2$s" not found' ); |
|
481 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $domain, $code ) ); |
|
480 | + $msg = $context->getI18n()->dt('controller/frontend', 'List type for domain "%1$s" and code "%2$s" not found'); |
|
481 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $domain, $code)); |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | return $this->listTypeItems[$domain][$code]; |
@@ -493,35 +493,35 @@ discard block |
||
493 | 493 | * @param array $domains Names of the domain items that should be fetched too |
494 | 494 | * @return array List of products matching the given attributes |
495 | 495 | */ |
496 | - protected function getProductVariants( \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
497 | - array $domains = array( 'attribute', 'media', 'price', 'text' ) ) |
|
496 | + protected function getProductVariants(\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
497 | + array $domains = array('attribute', 'media', 'price', 'text')) |
|
498 | 498 | { |
499 | 499 | $subProductIds = []; |
500 | - foreach( $productItem->getRefItems( 'product', 'default', 'default' ) as $item ) { |
|
500 | + foreach ($productItem->getRefItems('product', 'default', 'default') as $item) { |
|
501 | 501 | $subProductIds[] = $item->getId(); |
502 | 502 | } |
503 | 503 | |
504 | - if( count( $subProductIds ) === 0 ) { |
|
504 | + if (count($subProductIds) === 0) { |
|
505 | 505 | return []; |
506 | 506 | } |
507 | 507 | |
508 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
509 | - $search = $productManager->createSearch( true ); |
|
508 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
509 | + $search = $productManager->createSearch(true); |
|
510 | 510 | |
511 | 511 | $expr = array( |
512 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
512 | + $search->compare('==', 'product.id', $subProductIds), |
|
513 | 513 | $search->getConditions(), |
514 | 514 | ); |
515 | 515 | |
516 | - foreach( $variantAttributeIds as $id ) |
|
516 | + foreach ($variantAttributeIds as $id) |
|
517 | 517 | { |
518 | - $cmpfunc = $search->createFunction( 'product:has', ['attribute', 'variant', (string) $id] ); |
|
519 | - $expr[] = $search->compare( '!=', $cmpfunc, null ); |
|
518 | + $cmpfunc = $search->createFunction('product:has', ['attribute', 'variant', (string) $id]); |
|
519 | + $expr[] = $search->compare('!=', $cmpfunc, null); |
|
520 | 520 | } |
521 | 521 | |
522 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
522 | + $search->setConditions($search->combine('&&', $expr)); |
|
523 | 523 | |
524 | - return $productManager->searchItems( $search, $domains ); |
|
524 | + return $productManager->searchItems($search, $domains); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | |
@@ -533,9 +533,9 @@ discard block |
||
533 | 533 | * @param mixed $default Default value if no value is available for the given name |
534 | 534 | * @return mixed Value from the array or default value |
535 | 535 | */ |
536 | - protected function getValue( array $values, $name, $default = null ) |
|
536 | + protected function getValue(array $values, $name, $default = null) |
|
537 | 537 | { |
538 | - if( isset( $values[$name] ) ) { |
|
538 | + if (isset($values[$name])) { |
|
539 | 539 | return $values[$name]; |
540 | 540 | } |
541 | 541 |
@@ -17,22 +17,22 @@ discard block |
||
17 | 17 | protected function setUp() |
18 | 18 | { |
19 | 19 | $this->context = \TestHelperFrontend::getContext(); |
20 | - $this->object = new \Aimeos\Controller\Frontend\Product\Standard( $this->context ); |
|
20 | + $this->object = new \Aimeos\Controller\Frontend\Product\Standard($this->context); |
|
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 testAggregate() |
31 | 31 | { |
32 | 32 | $filter = $this->object->createFilter(); |
33 | - $list = $this->object->aggregate( $filter, 'index.attribute.id' ); |
|
33 | + $list = $this->object->aggregate($filter, 'index.attribute.id'); |
|
34 | 34 | |
35 | - $this->assertGreaterThan( 0, count( $list ) ); |
|
35 | + $this->assertGreaterThan(0, count($list)); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
@@ -40,128 +40,128 @@ discard block |
||
40 | 40 | { |
41 | 41 | $filter = $this->object->createFilter(); |
42 | 42 | |
43 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
44 | - $this->assertEquals( [], $filter->getSortations() ); |
|
45 | - $this->assertEquals( 0, $filter->getSliceStart() ); |
|
46 | - $this->assertEquals( 100, $filter->getSliceSize() ); |
|
43 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
44 | + $this->assertEquals([], $filter->getSortations()); |
|
45 | + $this->assertEquals(0, $filter->getSliceStart()); |
|
46 | + $this->assertEquals(100, $filter->getSliceSize()); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
50 | 50 | public function testCreateFilterIgnoreDates() |
51 | 51 | { |
52 | - $this->context->getConfig()->set( 'controller/frontend/product/ignore-dates', true ); |
|
52 | + $this->context->getConfig()->set('controller/frontend/product/ignore-dates', true); |
|
53 | 53 | |
54 | 54 | $filter = $this->object->createFilter(); |
55 | 55 | |
56 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
56 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
60 | 60 | public function testAddFilterAttribute() |
61 | 61 | { |
62 | 62 | $filter = $this->object->createFilter(); |
63 | - $filter = $this->object->addFilterAttribute( $filter, array( 1, 2 ), [], [] ); |
|
63 | + $filter = $this->object->addFilterAttribute($filter, array(1, 2), [], []); |
|
64 | 64 | |
65 | 65 | $list = $filter->getConditions()->getExpressions(); |
66 | 66 | |
67 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
68 | - throw new \RuntimeException( 'Wrong expression' ); |
|
67 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
68 | + throw new \RuntimeException('Wrong expression'); |
|
69 | 69 | } |
70 | 70 | |
71 | - $this->assertEquals( 'index.attribute:all([1,2])', $list[0]->getName() ); |
|
71 | + $this->assertEquals('index.attribute:all([1,2])', $list[0]->getName()); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
75 | 75 | public function testAddFilterAttributeOptions() |
76 | 76 | { |
77 | 77 | $filter = $this->object->createFilter(); |
78 | - $filter = $this->object->addFilterAttribute( $filter, [], array( 1 ), [] ); |
|
78 | + $filter = $this->object->addFilterAttribute($filter, [], array(1), []); |
|
79 | 79 | |
80 | 80 | $list = $filter->getConditions()->getExpressions(); |
81 | 81 | |
82 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
83 | - throw new \RuntimeException( 'Wrong expression' ); |
|
82 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
83 | + throw new \RuntimeException('Wrong expression'); |
|
84 | 84 | } |
85 | 85 | |
86 | - $this->assertEquals( 'index.attribute.id', $list[0]->getName() ); |
|
87 | - $this->assertEquals( [1], $list[0]->getValue() ); |
|
86 | + $this->assertEquals('index.attribute.id', $list[0]->getName()); |
|
87 | + $this->assertEquals([1], $list[0]->getValue()); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | |
91 | 91 | public function testAddFilterAttributeOne() |
92 | 92 | { |
93 | 93 | $filter = $this->object->createFilter(); |
94 | - $filter = $this->object->addFilterAttribute( $filter, [], [], array( 'test' => array( 2 ) ) ); |
|
94 | + $filter = $this->object->addFilterAttribute($filter, [], [], array('test' => array(2))); |
|
95 | 95 | |
96 | 96 | $list = $filter->getConditions()->getExpressions(); |
97 | 97 | |
98 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
99 | - throw new \RuntimeException( 'Wrong expression' ); |
|
98 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
99 | + throw new \RuntimeException('Wrong expression'); |
|
100 | 100 | } |
101 | 101 | |
102 | - $this->assertEquals( 'index.attribute.id', $list[0]->getName() ); |
|
103 | - $this->assertEquals( [2], $list[0]->getValue() ); |
|
102 | + $this->assertEquals('index.attribute.id', $list[0]->getName()); |
|
103 | + $this->assertEquals([2], $list[0]->getValue()); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | |
107 | 107 | public function testAddFilterCategory() |
108 | 108 | { |
109 | 109 | $context = \TestHelperFrontend::getContext(); |
110 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'catalog' ); |
|
110 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'catalog'); |
|
111 | 111 | |
112 | - $catId = $manager->findItem( 'root' )->getId(); |
|
112 | + $catId = $manager->findItem('root')->getId(); |
|
113 | 113 | $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST; |
114 | 114 | |
115 | 115 | $filter = $this->object->createFilter(); |
116 | - $filter = $this->object->addFilterCategory( $filter, $catId, $level ); |
|
116 | + $filter = $this->object->addFilterCategory($filter, $catId, $level); |
|
117 | 117 | |
118 | 118 | $list = $filter->getConditions()->getExpressions(); |
119 | 119 | |
120 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
121 | - throw new \RuntimeException( 'Wrong expression' ); |
|
120 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
121 | + throw new \RuntimeException('Wrong expression'); |
|
122 | 122 | } |
123 | 123 | |
124 | - $this->assertEquals( 'index.catalog.id', $list[0]->getName() ); |
|
125 | - $this->assertEquals( 3, count( $list[0]->getValue() ) ); |
|
126 | - $this->assertEquals( [], $filter->getSortations() ); |
|
124 | + $this->assertEquals('index.catalog.id', $list[0]->getName()); |
|
125 | + $this->assertEquals(3, count($list[0]->getValue())); |
|
126 | + $this->assertEquals([], $filter->getSortations()); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
130 | 130 | public function testAddFilterSupplier() |
131 | 131 | { |
132 | 132 | $filter = $this->object->createFilter(); |
133 | - $filter = $this->object->addFilterSupplier( $filter, [1, 2] ); |
|
133 | + $filter = $this->object->addFilterSupplier($filter, [1, 2]); |
|
134 | 134 | |
135 | 135 | $list = $filter->getConditions()->getExpressions(); |
136 | 136 | |
137 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
138 | - throw new \RuntimeException( 'Wrong expression' ); |
|
137 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
138 | + throw new \RuntimeException('Wrong expression'); |
|
139 | 139 | } |
140 | 140 | |
141 | - $this->assertEquals( 'index.supplier.id', $list[0]->getName() ); |
|
142 | - $this->assertEquals( 2, count( $list[0]->getValue() ) ); |
|
141 | + $this->assertEquals('index.supplier.id', $list[0]->getName()); |
|
142 | + $this->assertEquals(2, count($list[0]->getValue())); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | |
146 | 146 | public function testAddFilterText() |
147 | 147 | { |
148 | 148 | $filter = $this->object->createFilter(); |
149 | - $filter = $this->object->addFilterText( $filter, 'Espresso' ); |
|
149 | + $filter = $this->object->addFilterText($filter, 'Espresso'); |
|
150 | 150 | |
151 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
151 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
152 | 152 | |
153 | 153 | $list = $filter->getConditions()->getExpressions(); |
154 | 154 | |
155 | 155 | |
156 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
157 | - throw new \RuntimeException( 'Wrong expression' ); |
|
156 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
157 | + throw new \RuntimeException('Wrong expression'); |
|
158 | 158 | } |
159 | - $this->assertEquals( 'index.text:relevance("default","de","Espresso")', $list[0]->getName() ); |
|
160 | - $this->assertEquals( 0, $list[0]->getValue() ); |
|
159 | + $this->assertEquals('index.text:relevance("default","de","Espresso")', $list[0]->getName()); |
|
160 | + $this->assertEquals(0, $list[0]->getValue()); |
|
161 | 161 | |
162 | - $this->assertEquals( [], $filter->getSortations() ); |
|
163 | - $this->assertEquals( 0, $filter->getSliceStart() ); |
|
164 | - $this->assertEquals( 100, $filter->getSliceSize() ); |
|
162 | + $this->assertEquals([], $filter->getSortations()); |
|
163 | + $this->assertEquals(0, $filter->getSliceStart()); |
|
164 | + $this->assertEquals(100, $filter->getSliceSize()); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -170,177 +170,177 @@ discard block |
||
170 | 170 | $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE; |
171 | 171 | |
172 | 172 | $filter = $this->object->createFilter(); |
173 | - $filter = $this->object->addFilterCategory( $filter, 0, $level, 'relevance', '-', 'test' ); |
|
173 | + $filter = $this->object->addFilterCategory($filter, 0, $level, 'relevance', '-', 'test'); |
|
174 | 174 | |
175 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
175 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
176 | 176 | |
177 | 177 | $sort = $filter->getSortations(); |
178 | - if( ( $item = reset( $sort ) ) === false ) { |
|
179 | - throw new \RuntimeException( 'Sortation not set' ); |
|
178 | + if (($item = reset($sort)) === false) { |
|
179 | + throw new \RuntimeException('Sortation not set'); |
|
180 | 180 | } |
181 | 181 | |
182 | - $this->assertEquals( 'sort:index.catalog:position("test",["0"])', $item->getName() ); |
|
183 | - $this->assertEquals( '-', $item->getOperator() ); |
|
182 | + $this->assertEquals('sort:index.catalog:position("test",["0"])', $item->getName()); |
|
183 | + $this->assertEquals('-', $item->getOperator()); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | |
187 | 187 | public function testCreateFilterSortRelevanceText() |
188 | 188 | { |
189 | - $filter = $this->object->createFilter( 'relevance', '-', 1, 2, 'test' ); |
|
190 | - $filter = $this->object->addFilterText( $filter, 'Espresso' ); |
|
189 | + $filter = $this->object->createFilter('relevance', '-', 1, 2, 'test'); |
|
190 | + $filter = $this->object->addFilterText($filter, 'Espresso'); |
|
191 | 191 | |
192 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
193 | - $this->assertEquals( [], $filter->getSortations() ); |
|
194 | - $this->assertEquals( 1, $filter->getSliceStart() ); |
|
195 | - $this->assertEquals( 2, $filter->getSliceSize() ); |
|
192 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
193 | + $this->assertEquals([], $filter->getSortations()); |
|
194 | + $this->assertEquals(1, $filter->getSliceStart()); |
|
195 | + $this->assertEquals(2, $filter->getSliceSize()); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | |
199 | 199 | public function testCreateFilterSortCode() |
200 | 200 | { |
201 | - $filter = $this->object->createFilter( 'code' ); |
|
201 | + $filter = $this->object->createFilter('code'); |
|
202 | 202 | |
203 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
203 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
204 | 204 | |
205 | 205 | $sort = $filter->getSortations(); |
206 | - if( ( $item = reset( $sort ) ) === false ) { |
|
207 | - throw new \RuntimeException( 'Sortation not set' ); |
|
206 | + if (($item = reset($sort)) === false) { |
|
207 | + throw new \RuntimeException('Sortation not set'); |
|
208 | 208 | } |
209 | 209 | |
210 | - $this->assertEquals( 'product.code', $item->getName() ); |
|
210 | + $this->assertEquals('product.code', $item->getName()); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
214 | 214 | public function testCreateFilterSortCtime() |
215 | 215 | { |
216 | - $filter = $this->object->createFilter( 'ctime' ); |
|
216 | + $filter = $this->object->createFilter('ctime'); |
|
217 | 217 | |
218 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
218 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
219 | 219 | |
220 | 220 | $sort = $filter->getSortations(); |
221 | - if( ( $item = reset( $sort ) ) === false ) { |
|
222 | - throw new \RuntimeException( 'Sortation not set' ); |
|
221 | + if (($item = reset($sort)) === false) { |
|
222 | + throw new \RuntimeException('Sortation not set'); |
|
223 | 223 | } |
224 | 224 | |
225 | - $this->assertEquals( 'product.ctime', $item->getName() ); |
|
225 | + $this->assertEquals('product.ctime', $item->getName()); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | |
229 | 229 | public function testCreateFilterSortName() |
230 | 230 | { |
231 | - $filter = $this->object->createFilter( 'name' ); |
|
231 | + $filter = $this->object->createFilter('name'); |
|
232 | 232 | |
233 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
233 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
234 | 234 | |
235 | 235 | $sort = $filter->getSortations(); |
236 | - if( ( $item = reset( $sort ) ) === false ) { |
|
237 | - throw new \RuntimeException( 'Sortation not set' ); |
|
236 | + if (($item = reset($sort)) === false) { |
|
237 | + throw new \RuntimeException('Sortation not set'); |
|
238 | 238 | } |
239 | 239 | |
240 | - $this->assertEquals( 'sort:index.text:name("de")', $item->getName() ); |
|
240 | + $this->assertEquals('sort:index.text:name("de")', $item->getName()); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
244 | 244 | public function testCreateFilterSortPrice() |
245 | 245 | { |
246 | - $filter = $this->object->createFilter( 'price' ); |
|
246 | + $filter = $this->object->createFilter('price'); |
|
247 | 247 | |
248 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
248 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
249 | 249 | |
250 | 250 | $sort = $filter->getSortations(); |
251 | - if( ( $item = reset( $sort ) ) === false ) { |
|
252 | - throw new \RuntimeException( 'Sortation not set' ); |
|
251 | + if (($item = reset($sort)) === false) { |
|
252 | + throw new \RuntimeException('Sortation not set'); |
|
253 | 253 | } |
254 | 254 | |
255 | - $this->assertStringStartsWith( 'sort:index.price:value("default","EUR","default")', $item->getName() ); |
|
255 | + $this->assertStringStartsWith('sort:index.price:value("default","EUR","default")', $item->getName()); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | |
259 | 259 | public function testCreateFilterSortInvalid() |
260 | 260 | { |
261 | - $filter = $this->object->createFilter( '', 'failure' ); |
|
261 | + $filter = $this->object->createFilter('', 'failure'); |
|
262 | 262 | |
263 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
264 | - $this->assertEquals( [], $filter->getSortations() ); |
|
263 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
264 | + $this->assertEquals([], $filter->getSortations()); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | |
268 | 268 | public function testGetItem() |
269 | 269 | { |
270 | 270 | $context = \TestHelperFrontend::getContext(); |
271 | - $id = \Aimeos\MShop\Factory::createManager( $context, 'product' )->findItem( 'CNC' )->getId(); |
|
271 | + $id = \Aimeos\MShop\Factory::createManager($context, 'product')->findItem('CNC')->getId(); |
|
272 | 272 | |
273 | - $result = $this->object->getItem( $id ); |
|
273 | + $result = $this->object->getItem($id); |
|
274 | 274 | |
275 | - $this->assertInstanceOf( '\Aimeos\MShop\Product\Item\Iface', $result ); |
|
276 | - $this->assertGreaterThan( 0, $result->getPropertyItems() ); |
|
277 | - $this->assertGreaterThan( 0, $result->getRefItems( 'attribute' ) ); |
|
278 | - $this->assertGreaterThan( 0, $result->getRefItems( 'media' ) ); |
|
279 | - $this->assertGreaterThan( 0, $result->getRefItems( 'price' ) ); |
|
280 | - $this->assertGreaterThan( 0, $result->getRefItems( 'product' ) ); |
|
281 | - $this->assertGreaterThan( 0, $result->getRefItems( 'text' ) ); |
|
275 | + $this->assertInstanceOf('\Aimeos\MShop\Product\Item\Iface', $result); |
|
276 | + $this->assertGreaterThan(0, $result->getPropertyItems()); |
|
277 | + $this->assertGreaterThan(0, $result->getRefItems('attribute')); |
|
278 | + $this->assertGreaterThan(0, $result->getRefItems('media')); |
|
279 | + $this->assertGreaterThan(0, $result->getRefItems('price')); |
|
280 | + $this->assertGreaterThan(0, $result->getRefItems('product')); |
|
281 | + $this->assertGreaterThan(0, $result->getRefItems('text')); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
285 | 285 | public function testGetItems() |
286 | 286 | { |
287 | 287 | $context = \TestHelperFrontend::getContext(); |
288 | - $context->getConfig()->set( 'controller/frontend/product/ignore-dates', true ); |
|
288 | + $context->getConfig()->set('controller/frontend/product/ignore-dates', true); |
|
289 | 289 | |
290 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
290 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
291 | 291 | |
292 | 292 | $search = $manager->createSearch(); |
293 | - $search->setConditions( $search->compare( '==', 'product.code', array( 'CNC', 'CNE' ) ) ); |
|
293 | + $search->setConditions($search->compare('==', 'product.code', array('CNC', 'CNE'))); |
|
294 | 294 | |
295 | 295 | $ids = []; |
296 | - foreach( $manager->searchItems( $search ) as $productItem ) { |
|
296 | + foreach ($manager->searchItems($search) as $productItem) { |
|
297 | 297 | $ids[] = $productItem->getId(); |
298 | 298 | } |
299 | 299 | |
300 | 300 | |
301 | - $result = $this->object->getItems( $ids ); |
|
301 | + $result = $this->object->getItems($ids); |
|
302 | 302 | |
303 | - $this->assertEquals( 2, count( $result ) ); |
|
303 | + $this->assertEquals(2, count($result)); |
|
304 | 304 | |
305 | - foreach( $result as $productItem ) { |
|
306 | - $this->assertInstanceOf( '\Aimeos\MShop\Product\Item\Iface', $productItem ); |
|
305 | + foreach ($result as $productItem) { |
|
306 | + $this->assertInstanceOf('\Aimeos\MShop\Product\Item\Iface', $productItem); |
|
307 | 307 | } |
308 | 308 | } |
309 | 309 | |
310 | 310 | |
311 | 311 | public function testSearchItemsCategory() |
312 | 312 | { |
313 | - $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
313 | + $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
314 | 314 | $search = $catalogManager->createSearch(); |
315 | 315 | |
316 | - $search->setConditions( $search->compare( '==', 'catalog.code', 'new' ) ); |
|
317 | - $search->setSlice( 0, 1 ); |
|
318 | - $items = $catalogManager->searchItems( $search ); |
|
316 | + $search->setConditions($search->compare('==', 'catalog.code', 'new')); |
|
317 | + $search->setSlice(0, 1); |
|
318 | + $items = $catalogManager->searchItems($search); |
|
319 | 319 | |
320 | - if( ( $item = reset( $items ) ) === false ) { |
|
321 | - throw new \RuntimeException( 'Product item not found' ); |
|
320 | + if (($item = reset($items)) === false) { |
|
321 | + throw new \RuntimeException('Product item not found'); |
|
322 | 322 | } |
323 | 323 | |
324 | - $filter = $this->object->createFilter( 'position', '+', 1, 1 ); |
|
325 | - $filter = $this->object->addFilterCategory( $filter, $item->getId() ); |
|
324 | + $filter = $this->object->createFilter('position', '+', 1, 1); |
|
325 | + $filter = $this->object->addFilterCategory($filter, $item->getId()); |
|
326 | 326 | |
327 | 327 | $total = 0; |
328 | - $results = $this->object->searchItems( $filter, [], $total ); |
|
328 | + $results = $this->object->searchItems($filter, [], $total); |
|
329 | 329 | |
330 | - $this->assertEquals( 3, $total ); |
|
331 | - $this->assertEquals( 1, count( $results ) ); |
|
330 | + $this->assertEquals(3, $total); |
|
331 | + $this->assertEquals(1, count($results)); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | |
335 | 335 | public function testSearchItemsText() |
336 | 336 | { |
337 | - $filter = $this->object->createFilter( 'relevance', '+', 0, 1, 'unittype13' ); |
|
338 | - $filter = $this->object->addFilterText( $filter, 'Expresso', 'relevance', '+', 'unittype13' ); |
|
337 | + $filter = $this->object->createFilter('relevance', '+', 0, 1, 'unittype13'); |
|
338 | + $filter = $this->object->addFilterText($filter, 'Expresso', 'relevance', '+', 'unittype13'); |
|
339 | 339 | |
340 | 340 | $total = 0; |
341 | - $results = $this->object->searchItems( $filter, [], $total ); |
|
341 | + $results = $this->object->searchItems($filter, [], $total); |
|
342 | 342 | |
343 | - $this->assertEquals( 2, $total ); |
|
344 | - $this->assertEquals( 1, count( $results ) ); |
|
343 | + $this->assertEquals(2, $total); |
|
344 | + $this->assertEquals(1, count($results)); |
|
345 | 345 | } |
346 | 346 | } |