@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | * @param \Aimeos\Controller\Frontend\Iface $controller Controller object |
31 | 31 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects |
32 | 32 | */ |
33 | - public function __construct( \Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context ) |
|
33 | + public function __construct(\Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context) |
|
34 | 34 | { |
35 | - \Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Frontend\\Product\\Iface', $controller ); |
|
35 | + \Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Frontend\\Product\\Iface', $controller); |
|
36 | 36 | |
37 | 37 | $this->controller = $controller; |
38 | 38 | |
39 | - parent::__construct( $context ); |
|
39 | + parent::__construct($context); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | * @return mixed Returns the value of the called method |
49 | 49 | * @throws \Aimeos\Controller\Frontend\Exception If method call failed |
50 | 50 | */ |
51 | - public function __call( $name, array $param ) |
|
51 | + public function __call($name, array $param) |
|
52 | 52 | { |
53 | - return @call_user_func_array( array( $this->controller, $name ), $param ); |
|
53 | + return @call_user_func_array(array($this->controller, $name), $param); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
65 | 65 | * @since 2017.03 |
66 | 66 | */ |
67 | - public function addFilterAttribute( \Aimeos\MW\Criteria\Iface $filter, array $attrIds, array $optIds, array $oneIds ) |
|
67 | + public function addFilterAttribute(\Aimeos\MW\Criteria\Iface $filter, array $attrIds, array $optIds, array $oneIds) |
|
68 | 68 | { |
69 | - return $this->controller->addFilterAttribute( $filter, $attrIds, $optIds, $oneIds ); |
|
69 | + return $this->controller->addFilterAttribute($filter, $attrIds, $optIds, $oneIds); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | |
@@ -80,10 +80,10 @@ 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, $listtype = 'default' ) |
|
83 | + public function addFilterCategory(\Aimeos\MW\Criteria\Iface $filter, $catId, |
|
84 | + $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $listtype = 'default') |
|
85 | 85 | { |
86 | - return $this->controller->addFilterCategory( $filter, $catId, $level, $listtype ); |
|
86 | + return $this->controller->addFilterCategory($filter, $catId, $level, $listtype); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
96 | 96 | * @since 2018.07 |
97 | 97 | */ |
98 | - public function addFilterSupplier( \Aimeos\MW\Criteria\Iface $filter, array $supIds ) |
|
98 | + public function addFilterSupplier(\Aimeos\MW\Criteria\Iface $filter, array $supIds) |
|
99 | 99 | { |
100 | - return $this->controller->addFilterSupplier( $filter, $supIds ); |
|
100 | + return $this->controller->addFilterSupplier($filter, $supIds); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -109,9 +109,9 @@ discard block |
||
109 | 109 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
110 | 110 | * @since 2017.03 |
111 | 111 | */ |
112 | - public function addFilterText( \Aimeos\MW\Criteria\Iface $filter, $input ) |
|
112 | + public function addFilterText(\Aimeos\MW\Criteria\Iface $filter, $input) |
|
113 | 113 | { |
114 | - return $this->controller->addFilterText( $filter, $input ); |
|
114 | + return $this->controller->addFilterText($filter, $input); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | * @return array Associative list of key values as key and the product count for this key as value |
124 | 124 | * @since 2015.08 |
125 | 125 | */ |
126 | - public function aggregate( \Aimeos\MW\Criteria\Iface $filter, $key ) |
|
126 | + public function aggregate(\Aimeos\MW\Criteria\Iface $filter, $key) |
|
127 | 127 | { |
128 | - return $this->controller->aggregate( $filter, $key ); |
|
128 | + return $this->controller->aggregate($filter, $key); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
@@ -139,9 +139,9 @@ discard block |
||
139 | 139 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
140 | 140 | * @since 2015.08 |
141 | 141 | */ |
142 | - public function createFilter( $sort = null, $direction = '+', $start = 0, $size = 100 ) |
|
142 | + public function createFilter($sort = null, $direction = '+', $start = 0, $size = 100) |
|
143 | 143 | { |
144 | - return $this->controller->createFilter( $sort, $direction, $start, $size ); |
|
144 | + return $this->controller->createFilter($sort, $direction, $start, $size); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | |
@@ -153,9 +153,9 @@ discard block |
||
153 | 153 | * @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items |
154 | 154 | * @since 2017.03 |
155 | 155 | */ |
156 | - public function getItem( $productId, array $domains = array( 'attribute', 'media', 'price', 'product', 'product/property', 'text' ) ) |
|
156 | + public function getItem($productId, array $domains = array('attribute', 'media', 'price', 'product', 'product/property', 'text')) |
|
157 | 157 | { |
158 | - return $this->controller->getItem( $productId, $domains ); |
|
158 | + return $this->controller->getItem($productId, $domains); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | |
@@ -167,9 +167,9 @@ discard block |
||
167 | 167 | * @return \Aimeos\MShop\Product\Item\Iface[] Associative list of product IDs as keys and product items as values |
168 | 168 | * @since 2017.03 |
169 | 169 | */ |
170 | - public function getItems( array $productIds, array $domains = array( 'media', 'price', 'text' ) ) |
|
170 | + public function getItems(array $productIds, array $domains = array('media', 'price', 'text')) |
|
171 | 171 | { |
172 | - return $this->controller->getItems( $productIds, $domains ); |
|
172 | + return $this->controller->getItems($productIds, $domains); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface |
183 | 183 | * @since 2015.08 |
184 | 184 | */ |
185 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null ) |
|
185 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null) |
|
186 | 186 | { |
187 | - return $this->controller->searchItems( $filter, $domains, $total ); |
|
187 | + return $this->controller->searchItems($filter, $domains, $total); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 |
@@ -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 | /** |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
44 | 44 | * @since 2017.03 |
45 | 45 | */ |
46 | - public function addFilterCategory( \Aimeos\MW\Criteria\Iface $filter, $catId, |
|
47 | - $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $listtype = 'default' ); |
|
46 | + public function addFilterCategory(\Aimeos\MW\Criteria\Iface $filter, $catId, |
|
47 | + $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $listtype = 'default'); |
|
48 | 48 | |
49 | 49 | |
50 | 50 | /** |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
56 | 56 | * @since 2018.07 |
57 | 57 | */ |
58 | - public function addFilterSupplier( \Aimeos\MW\Criteria\Iface $filter, array $supIds ); |
|
58 | + public function addFilterSupplier(\Aimeos\MW\Criteria\Iface $filter, array $supIds); |
|
59 | 59 | |
60 | 60 | |
61 | 61 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
67 | 67 | * @since 2017.03 |
68 | 68 | */ |
69 | - public function addFilterText( \Aimeos\MW\Criteria\Iface $filter, $input ); |
|
69 | + public function addFilterText(\Aimeos\MW\Criteria\Iface $filter, $input); |
|
70 | 70 | |
71 | 71 | |
72 | 72 | /** |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @return array Associative list of key values as key and the product count for this key as value |
78 | 78 | * @since 2017.03 |
79 | 79 | */ |
80 | - public function aggregate( \Aimeos\MW\Criteria\Iface $filter, $key ); |
|
80 | + public function aggregate(\Aimeos\MW\Criteria\Iface $filter, $key); |
|
81 | 81 | |
82 | 82 | |
83 | 83 | /** |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
91 | 91 | * @since 2017.03 |
92 | 92 | */ |
93 | - public function createFilter( $sort = null, $direction = '+', $start = 0, $size = 100 ); |
|
93 | + public function createFilter($sort = null, $direction = '+', $start = 0, $size = 100); |
|
94 | 94 | |
95 | 95 | |
96 | 96 | /** |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items |
102 | 102 | * @since 2017.03 |
103 | 103 | */ |
104 | - public function getItem( $productId, array $domains = array( 'attribute', 'media', 'price', 'product', 'product/property', 'text' ) ); |
|
104 | + public function getItem($productId, array $domains = array('attribute', 'media', 'price', 'product', 'product/property', 'text')); |
|
105 | 105 | |
106 | 106 | |
107 | 107 | /** |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @return \Aimeos\MShop\Product\Item\Iface[] Associative list of product IDs as keys and product items as values |
113 | 113 | * @since 2017.03 |
114 | 114 | */ |
115 | - public function getItems( array $productIds, array $domains = array( 'media', 'price', 'text' ) ); |
|
115 | + public function getItems(array $productIds, array $domains = array('media', 'price', 'text')); |
|
116 | 116 | |
117 | 117 | |
118 | 118 | /** |
@@ -124,5 +124,5 @@ discard block |
||
124 | 124 | * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface |
125 | 125 | * @since 2017.03 |
126 | 126 | */ |
127 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null ); |
|
127 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null); |
|
128 | 128 | } |
@@ -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 | |
@@ -78,42 +78,42 @@ discard block |
||
78 | 78 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
79 | 79 | * @since 2017.03 |
80 | 80 | */ |
81 | - public function addFilterCategory( \Aimeos\MW\Criteria\Iface $filter, $catId, |
|
82 | - $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $listtype = 'default' ) |
|
81 | + public function addFilterCategory(\Aimeos\MW\Criteria\Iface $filter, $catId, |
|
82 | + $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $listtype = 'default') |
|
83 | 83 | { |
84 | - $catIds = ( !is_array( $catId ) ? explode( ',', $catId ) : $catId ); |
|
84 | + $catIds = (!is_array($catId) ? explode(',', $catId) : $catId); |
|
85 | 85 | |
86 | - if( $level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ) |
|
86 | + if ($level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE) |
|
87 | 87 | { |
88 | 88 | $list = []; |
89 | - $cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'catalog' ); |
|
89 | + $cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'catalog'); |
|
90 | 90 | |
91 | - foreach( $catIds as $catId ) |
|
91 | + foreach ($catIds as $catId) |
|
92 | 92 | { |
93 | - $tree = $cntl->getTree( $catId, [], $level ); |
|
94 | - $list = array_merge( $list, $this->getCatalogIdsFromTree( $tree ) ); |
|
93 | + $tree = $cntl->getTree($catId, [], $level); |
|
94 | + $list = array_merge($list, $this->getCatalogIdsFromTree($tree)); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | $catIds = $list; |
98 | 98 | } |
99 | 99 | |
100 | - $expr = array( $filter->compare( '==', 'index.catalog.id', array_unique( $catIds ) ) ); |
|
100 | + $expr = array($filter->compare('==', 'index.catalog.id', array_unique($catIds))); |
|
101 | 101 | $expr[] = $filter->getConditions(); |
102 | 102 | |
103 | - if( isset( $filter->sortname ) && $filter->sortname === 'relevance' ) |
|
103 | + if (isset($filter->sortname) && $filter->sortname === 'relevance') |
|
104 | 104 | { |
105 | 105 | $start = $filter->getSliceStart(); |
106 | 106 | $end = $start + $filter->getSliceSize(); |
107 | - $dir = ( isset( $filter->sortdir ) ? $filter->sortdir : '+' ); |
|
107 | + $dir = (isset($filter->sortdir) ? $filter->sortdir : '+'); |
|
108 | 108 | |
109 | - $cmpfunc = $filter->createFunction( 'index.catalog:position', array( $listtype, $catIds, $start, $end ) ); |
|
110 | - $expr[] = $filter->compare( '>=', $cmpfunc, 0 ); |
|
109 | + $cmpfunc = $filter->createFunction('index.catalog:position', array($listtype, $catIds, $start, $end)); |
|
110 | + $expr[] = $filter->compare('>=', $cmpfunc, 0); |
|
111 | 111 | |
112 | - $sortfunc = $filter->createFunction( 'sort:index.catalog:position', array( $listtype, $catIds, $start, $end ) ); |
|
113 | - $filter->setSortations( [$filter->sort( $dir, $sortfunc ), $filter->sort( '+', 'product.id' )] ); |
|
112 | + $sortfunc = $filter->createFunction('sort:index.catalog:position', array($listtype, $catIds, $start, $end)); |
|
113 | + $filter->setSortations([$filter->sort($dir, $sortfunc), $filter->sort('+', 'product.id')]); |
|
114 | 114 | } |
115 | 115 | |
116 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
116 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
117 | 117 | |
118 | 118 | return $filter; |
119 | 119 | } |
@@ -127,16 +127,16 @@ discard block |
||
127 | 127 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
128 | 128 | * @since 2018.07 |
129 | 129 | */ |
130 | - public function addFilterSupplier( \Aimeos\MW\Criteria\Iface $filter, array $supIds ) |
|
130 | + public function addFilterSupplier(\Aimeos\MW\Criteria\Iface $filter, array $supIds) |
|
131 | 131 | { |
132 | - if( !empty( $supIds ) ) |
|
132 | + if (!empty($supIds)) |
|
133 | 133 | { |
134 | - $supIds = $this->validateIds( $supIds ); |
|
134 | + $supIds = $this->validateIds($supIds); |
|
135 | 135 | $expr = array( |
136 | - $filter->compare( '==', 'index.supplier.id', $supIds ), |
|
136 | + $filter->compare('==', 'index.supplier.id', $supIds), |
|
137 | 137 | $filter->getConditions(), |
138 | 138 | ); |
139 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
139 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | return $filter; |
@@ -151,13 +151,13 @@ discard block |
||
151 | 151 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
152 | 152 | * @since 2017.03 |
153 | 153 | */ |
154 | - public function addFilterText( \Aimeos\MW\Criteria\Iface $filter, $input ) |
|
154 | + public function addFilterText(\Aimeos\MW\Criteria\Iface $filter, $input) |
|
155 | 155 | { |
156 | 156 | $langid = $this->getContext()->getLocale()->getLanguageId(); |
157 | - $cmpfunc = $filter->createFunction( 'index.text:relevance', [$langid, $input] ); |
|
158 | - $expr = array( $filter->compare( '>', $cmpfunc, 0 ), $filter->getConditions() ); |
|
157 | + $cmpfunc = $filter->createFunction('index.text:relevance', [$langid, $input]); |
|
158 | + $expr = array($filter->compare('>', $cmpfunc, 0), $filter->getConditions()); |
|
159 | 159 | |
160 | - return $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
160 | + return $filter->setConditions($filter->combine('&&', $expr)); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | |
@@ -169,9 +169,9 @@ discard block |
||
169 | 169 | * @return array Associative list of key values as key and the product count for this key as value |
170 | 170 | * @since 2017.03 |
171 | 171 | */ |
172 | - public function aggregate( \Aimeos\MW\Criteria\Iface $filter, $key ) |
|
172 | + public function aggregate(\Aimeos\MW\Criteria\Iface $filter, $key) |
|
173 | 173 | { |
174 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->aggregate( $filter, $key ); |
|
174 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->aggregate($filter, $key); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
186 | 186 | * @since 2017.03 |
187 | 187 | */ |
188 | - public function createFilter( $sort = null, $direction = '+', $start = 0, $size = 100 ) |
|
188 | + public function createFilter($sort = null, $direction = '+', $start = 0, $size = 100) |
|
189 | 189 | { |
190 | 190 | $sortations = []; |
191 | 191 | $context = $this->getContext(); |
192 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'index' ); |
|
192 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'index'); |
|
193 | 193 | |
194 | 194 | |
195 | 195 | /** controller/frontend/product/ignore-dates |
@@ -204,55 +204,55 @@ discard block |
||
204 | 204 | * @since 2017.10 |
205 | 205 | * @category Developer |
206 | 206 | */ |
207 | - if( $context->getConfig()->get( 'controller/frontend/product/ignore-dates', false ) ) |
|
207 | + if ($context->getConfig()->get('controller/frontend/product/ignore-dates', false)) |
|
208 | 208 | { |
209 | 209 | $search = $manager->createSearch(); |
210 | - $search->setConditions( $search->compare( '>', 'product.status', 0 ) ); |
|
210 | + $search->setConditions($search->compare('>', 'product.status', 0)); |
|
211 | 211 | } |
212 | 212 | else |
213 | 213 | { |
214 | - $search = $manager->createSearch( true ); |
|
214 | + $search = $manager->createSearch(true); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | |
218 | - $expr = array( $search->compare( '!=', 'index.catalog.id', null ) ); |
|
218 | + $expr = array($search->compare('!=', 'index.catalog.id', null)); |
|
219 | 219 | |
220 | - switch( $sort ) |
|
220 | + switch ($sort) |
|
221 | 221 | { |
222 | 222 | case 'code': |
223 | - $sortations[] = $search->sort( $direction, 'product.code' ); |
|
223 | + $sortations[] = $search->sort($direction, 'product.code'); |
|
224 | 224 | break; |
225 | 225 | |
226 | 226 | case 'ctime': |
227 | - $sortations[] = $search->sort( $direction, 'product.ctime' ); |
|
227 | + $sortations[] = $search->sort($direction, 'product.ctime'); |
|
228 | 228 | break; |
229 | 229 | |
230 | 230 | case 'name': |
231 | 231 | $langid = $context->getLocale()->getLanguageId(); |
232 | 232 | |
233 | - $cmpfunc = $search->createFunction( 'index.text:name', [$langid] ); |
|
234 | - $expr[] = $search->compare( '!=', $cmpfunc, null ); |
|
233 | + $cmpfunc = $search->createFunction('index.text:name', [$langid]); |
|
234 | + $expr[] = $search->compare('!=', $cmpfunc, null); |
|
235 | 235 | |
236 | - $sortfunc = $search->createFunction( 'sort:index.text:name', [$langid] ); |
|
237 | - $sortations[] = $search->sort( $direction, $sortfunc ); |
|
236 | + $sortfunc = $search->createFunction('sort:index.text:name', [$langid]); |
|
237 | + $sortations[] = $search->sort($direction, $sortfunc); |
|
238 | 238 | break; |
239 | 239 | |
240 | 240 | case 'price': |
241 | 241 | $currencyid = $context->getLocale()->getCurrencyId(); |
242 | 242 | |
243 | - $cmpfunc = $search->createFunction( 'index.price:value', ['default', $currencyid, 'default'] ); |
|
244 | - $expr[] = $search->compare( '!=', $cmpfunc, null ); |
|
243 | + $cmpfunc = $search->createFunction('index.price:value', ['default', $currencyid, 'default']); |
|
244 | + $expr[] = $search->compare('!=', $cmpfunc, null); |
|
245 | 245 | |
246 | - $sortfunc = $search->createFunction( 'sort:index.price:value', ['default', $currencyid, 'default'] ); |
|
247 | - $sortations[] = $search->sort( $direction, $sortfunc ); |
|
246 | + $sortfunc = $search->createFunction('sort:index.price:value', ['default', $currencyid, 'default']); |
|
247 | + $sortations[] = $search->sort($direction, $sortfunc); |
|
248 | 248 | break; |
249 | 249 | } |
250 | 250 | |
251 | 251 | $expr[] = $search->getConditions(); |
252 | 252 | |
253 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
254 | - $search->setSortations( $sortations ); |
|
255 | - $search->setSlice( $start, $size ); |
|
253 | + $search->setConditions($search->combine('&&', $expr)); |
|
254 | + $search->setSortations($sortations); |
|
255 | + $search->setSlice($start, $size); |
|
256 | 256 | $search->sortdir = $direction; |
257 | 257 | $search->sortname = $sort; |
258 | 258 | |
@@ -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 | } |
@@ -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("de","Espresso")', $list[0]->getName() ); |
|
160 | - $this->assertEquals( 0, $list[0]->getValue() ); |
|
159 | + $this->assertEquals('index.text:relevance("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 | |
@@ -169,177 +169,177 @@ discard block |
||
169 | 169 | { |
170 | 170 | $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE; |
171 | 171 | |
172 | - $filter = $this->object->createFilter( 'relevance', '-' ); |
|
173 | - $filter = $this->object->addFilterCategory( $filter, 0, $level, 'test' ); |
|
172 | + $filter = $this->object->createFilter('relevance', '-'); |
|
173 | + $filter = $this->object->addFilterCategory($filter, 0, $level, '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"],0,100)', $item->getName() ); |
|
183 | - $this->assertEquals( '-', $item->getOperator() ); |
|
182 | + $this->assertEquals('sort:index.catalog:position("test",["0"],0,100)', $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 ); |
|
190 | - $filter = $this->object->addFilterText( $filter, 'Espresso' ); |
|
189 | + $filter = $this->object->createFilter('relevance', '-', 1, 2); |
|
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 | |
315 | - $search = $catalogManager->createSearch()->setSlice( 0, 1 ); |
|
316 | - $search->setConditions( $search->compare( '==', 'catalog.code', 'new' ) ); |
|
317 | - $items = $catalogManager->searchItems( $search ); |
|
315 | + $search = $catalogManager->createSearch()->setSlice(0, 1); |
|
316 | + $search->setConditions($search->compare('==', 'catalog.code', 'new')); |
|
317 | + $items = $catalogManager->searchItems($search); |
|
318 | 318 | |
319 | - if( ( $item = reset( $items ) ) === false ) { |
|
320 | - throw new \RuntimeException( 'Product item not found' ); |
|
319 | + if (($item = reset($items)) === false) { |
|
320 | + throw new \RuntimeException('Product item not found'); |
|
321 | 321 | } |
322 | 322 | |
323 | - $filter = $this->object->createFilter( 'position', '+', 1, 1 ); |
|
324 | - $filter = $this->object->addFilterCategory( $filter, $item->getId() ); |
|
323 | + $filter = $this->object->createFilter('position', '+', 1, 1); |
|
324 | + $filter = $this->object->addFilterCategory($filter, $item->getId()); |
|
325 | 325 | |
326 | 326 | $total = 0; |
327 | - $results = $this->object->searchItems( $filter, [], $total ); |
|
327 | + $results = $this->object->searchItems($filter, [], $total); |
|
328 | 328 | |
329 | - $this->assertEquals( 3, $total ); |
|
330 | - $this->assertEquals( 1, count( $results ) ); |
|
329 | + $this->assertEquals(3, $total); |
|
330 | + $this->assertEquals(1, count($results)); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | |
334 | 334 | public function testSearchItemsText() |
335 | 335 | { |
336 | - $filter = $this->object->createFilter( 'relevance', '+', 0, 1 ); |
|
337 | - $filter = $this->object->addFilterText( $filter, 'Expresso' ); |
|
336 | + $filter = $this->object->createFilter('relevance', '+', 0, 1); |
|
337 | + $filter = $this->object->addFilterText($filter, 'Expresso'); |
|
338 | 338 | |
339 | 339 | $total = 0; |
340 | - $results = $this->object->searchItems( $filter, [], $total ); |
|
340 | + $results = $this->object->searchItems($filter, [], $total); |
|
341 | 341 | |
342 | - $this->assertEquals( 2, $total ); |
|
343 | - $this->assertEquals( 1, count( $results ) ); |
|
342 | + $this->assertEquals(2, $total); |
|
343 | + $this->assertEquals(1, count($results)); |
|
344 | 344 | } |
345 | 345 | } |