@@ -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, count( $attrIds ) ), |
|
40 | + $filter->compare('==', $func, count($attrIds)), |
|
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,25 +305,25 @@ 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->setSortations( [$search->sort( '+', 'product.type.position' )] ); |
|
324 | - $search->setSlice( 0, count( $productIds ) ); |
|
322 | + $search->setConditions($search->combine('&&', $expr)); |
|
323 | + $search->setSortations([$search->sort('+', 'product.type.position')]); |
|
324 | + $search->setSlice(0, count($productIds)); |
|
325 | 325 | |
326 | - return $manager->searchItems( $search, $domains ); |
|
326 | + return $manager->searchItems($search, $domains); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface |
337 | 337 | * @since 2017.03 |
338 | 338 | */ |
339 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null ) |
|
339 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null) |
|
340 | 340 | { |
341 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->searchItems( $filter, $domains, $total ); |
|
341 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->searchItems($filter, $domains, $total); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | |
@@ -348,16 +348,16 @@ discard block |
||
348 | 348 | * @param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item with children |
349 | 349 | * @return array List of catalog IDs |
350 | 350 | */ |
351 | - protected function getCatalogIdsFromTree( \Aimeos\MShop\Catalog\Item\Iface $item ) |
|
351 | + protected function getCatalogIdsFromTree(\Aimeos\MShop\Catalog\Item\Iface $item) |
|
352 | 352 | { |
353 | - if( $item->getStatus() < 1 ) { |
|
353 | + if ($item->getStatus() < 1) { |
|
354 | 354 | return []; |
355 | 355 | } |
356 | 356 | |
357 | - $list = [ $item->getId() ]; |
|
357 | + $list = [$item->getId()]; |
|
358 | 358 | |
359 | - foreach( $item->getChildren() as $child ) { |
|
360 | - $list = array_merge( $list, $this->getCatalogIdsFromTree( $child ) ); |
|
359 | + foreach ($item->getChildren() as $child) { |
|
360 | + $list = array_merge($list, $this->getCatalogIdsFromTree($child)); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | return $list; |
@@ -370,13 +370,13 @@ discard block |
||
370 | 370 | * @param array $ids List of IDs to validate |
371 | 371 | * @return array List of validated IDs |
372 | 372 | */ |
373 | - protected function validateIds( array $ids ) |
|
373 | + protected function validateIds(array $ids) |
|
374 | 374 | { |
375 | 375 | $list = []; |
376 | 376 | |
377 | - foreach( $ids as $id ) |
|
377 | + foreach ($ids as $id) |
|
378 | 378 | { |
379 | - if( $id != '' ) { |
|
379 | + if ($id != '') { |
|
380 | 380 | $list[] = (int) $id; |
381 | 381 | } |
382 | 382 | } |