|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2023 |
|
6
|
|
|
* @package Controller |
|
7
|
|
|
* @subpackage Frontend |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
namespace Aimeos\Controller\Frontend\Catalog; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Default implementation of the catalog frontend controller. |
|
16
|
|
|
* |
|
17
|
|
|
* @package Controller |
|
18
|
|
|
* @subpackage Frontend |
|
19
|
|
|
*/ |
|
20
|
|
|
class Standard |
|
21
|
|
|
extends \Aimeos\Controller\Frontend\Base |
|
22
|
|
|
implements Iface, \Aimeos\Controller\Frontend\Common\Iface |
|
23
|
|
|
{ |
|
24
|
|
|
/** controller/frontend/catalog/name |
|
25
|
|
|
* Class name of the used catalog frontend controller implementation |
|
26
|
|
|
* |
|
27
|
|
|
* Each default frontend controller can be replace by an alternative imlementation. |
|
28
|
|
|
* To use this implementation, you have to set the last part of the class |
|
29
|
|
|
* name as configuration value so the controller factory knows which class it |
|
30
|
|
|
* has to instantiate. |
|
31
|
|
|
* |
|
32
|
|
|
* For example, if the name of the default class is |
|
33
|
|
|
* |
|
34
|
|
|
* \Aimeos\Controller\Frontend\Catalog\Standard |
|
35
|
|
|
* |
|
36
|
|
|
* and you want to replace it with your own version named |
|
37
|
|
|
* |
|
38
|
|
|
* \Aimeos\Controller\Frontend\Catalog\Mycatalog |
|
39
|
|
|
* |
|
40
|
|
|
* then you have to set the this configuration option: |
|
41
|
|
|
* |
|
42
|
|
|
* controller/jobs/frontend/catalog/name = Mycatalog |
|
43
|
|
|
* |
|
44
|
|
|
* The value is the last part of your own class name and it's case sensitive, |
|
45
|
|
|
* so take care that the configuration value is exactly named like the last |
|
46
|
|
|
* part of the class name. |
|
47
|
|
|
* |
|
48
|
|
|
* The allowed characters of the class name are A-Z, a-z and 0-9. No other |
|
49
|
|
|
* characters are possible! You should always start the last part of the class |
|
50
|
|
|
* name with an upper case character and continue only with lower case characters |
|
51
|
|
|
* or numbers. Avoid chamel case names like "MyCatalog"! |
|
52
|
|
|
* |
|
53
|
|
|
* @param string Last part of the class name |
|
54
|
|
|
* @since 2014.03 |
|
55
|
|
|
* @category Developer |
|
56
|
|
|
*/ |
|
57
|
|
|
|
|
58
|
|
|
/** controller/frontend/catalog/decorators/excludes |
|
59
|
|
|
* Excludes decorators added by the "common" option from the catalog frontend controllers |
|
60
|
|
|
* |
|
61
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
|
62
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
|
63
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
|
64
|
|
|
* modify what is returned to the caller. |
|
65
|
|
|
* |
|
66
|
|
|
* This option allows you to remove a decorator added via |
|
67
|
|
|
* "controller/frontend/common/decorators/default" before they are wrapped |
|
68
|
|
|
* around the frontend controller. |
|
69
|
|
|
* |
|
70
|
|
|
* controller/frontend/catalog/decorators/excludes = array( 'decorator1' ) |
|
71
|
|
|
* |
|
72
|
|
|
* This would remove the decorator named "decorator1" from the list of |
|
73
|
|
|
* common decorators ("\Aimeos\Controller\Frontend\Common\Decorator\*") added via |
|
74
|
|
|
* "controller/frontend/common/decorators/default" for the catalog frontend controller. |
|
75
|
|
|
* |
|
76
|
|
|
* @param array List of decorator names |
|
77
|
|
|
* @since 2014.03 |
|
78
|
|
|
* @category Developers |
|
79
|
|
|
* @see controller/frontend/common/decorators/default |
|
80
|
|
|
* @see controller/frontend/catalog/decorators/global |
|
81
|
|
|
* @see controller/frontend/catalog/decorators/local |
|
82
|
|
|
*/ |
|
83
|
|
|
|
|
84
|
|
|
/** controller/frontend/catalog/decorators/global |
|
85
|
|
|
* Adds a list of globally available decorators only to the catalog frontend controllers |
|
86
|
|
|
* |
|
87
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
|
88
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
|
89
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
|
90
|
|
|
* modify what is returned to the caller. |
|
91
|
|
|
* |
|
92
|
|
|
* This option allows you to wrap global decorators |
|
93
|
|
|
* ("\Aimeos\Controller\Frontend\Common\Decorator\*") around the frontend controller. |
|
94
|
|
|
* |
|
95
|
|
|
* controller/frontend/catalog/decorators/global = array( 'decorator1' ) |
|
96
|
|
|
* |
|
97
|
|
|
* This would add the decorator named "decorator1" defined by |
|
98
|
|
|
* "\Aimeos\Controller\Frontend\Common\Decorator\Decorator1" only to the frontend controller. |
|
99
|
|
|
* |
|
100
|
|
|
* @param array List of decorator names |
|
101
|
|
|
* @since 2014.03 |
|
102
|
|
|
* @category Developers |
|
103
|
|
|
* @see controller/frontend/common/decorators/default |
|
104
|
|
|
* @see controller/frontend/catalog/decorators/excludes |
|
105
|
|
|
* @see controller/frontend/catalog/decorators/local |
|
106
|
|
|
*/ |
|
107
|
|
|
|
|
108
|
|
|
/** controller/frontend/catalog/decorators/local |
|
109
|
|
|
* Adds a list of local decorators only to the catalog frontend controllers |
|
110
|
|
|
* |
|
111
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
|
112
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
|
113
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
|
114
|
|
|
* modify what is returned to the caller. |
|
115
|
|
|
* |
|
116
|
|
|
* This option allows you to wrap local decorators |
|
117
|
|
|
* ("\Aimeos\Controller\Frontend\Catalog\Decorator\*") around the frontend controller. |
|
118
|
|
|
* |
|
119
|
|
|
* controller/frontend/catalog/decorators/local = array( 'decorator2' ) |
|
120
|
|
|
* |
|
121
|
|
|
* This would add the decorator named "decorator2" defined by |
|
122
|
|
|
* "\Aimeos\Controller\Frontend\Catalog\Decorator\Decorator2" only to the frontend |
|
123
|
|
|
* controller. |
|
124
|
|
|
* |
|
125
|
|
|
* @param array List of decorator names |
|
126
|
|
|
* @since 2014.03 |
|
127
|
|
|
* @category Developers |
|
128
|
|
|
* @see controller/frontend/common/decorators/default |
|
129
|
|
|
* @see controller/frontend/catalog/decorators/excludes |
|
130
|
|
|
* @see controller/frontend/catalog/decorators/global |
|
131
|
|
|
*/ |
|
132
|
|
|
|
|
133
|
|
|
|
|
134
|
|
|
private \Aimeos\MShop\Common\Manager\Iface $manager; |
|
135
|
|
|
private \Aimeos\Base\Criteria\Iface $filter; |
|
136
|
|
|
private ?string $root = null; |
|
137
|
|
|
private array $domains = []; |
|
138
|
|
|
|
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* Common initialization for controller classes |
|
142
|
|
|
* |
|
143
|
|
|
* @param \Aimeos\MShop\ContextIface $context Common MShop context object |
|
144
|
|
|
*/ |
|
145
|
|
|
public function __construct( \Aimeos\MShop\ContextIface $context ) |
|
146
|
|
|
{ |
|
147
|
|
|
parent::__construct( $context ); |
|
148
|
|
|
|
|
149
|
|
|
$this->manager = \Aimeos\MShop::create( $context, 'catalog' ); |
|
150
|
|
|
$this->filter = $this->manager->filter( true ); |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* Clones objects in controller |
|
156
|
|
|
*/ |
|
157
|
|
|
public function __clone() |
|
158
|
|
|
{ |
|
159
|
|
|
$this->filter = clone $this->filter; |
|
160
|
|
|
parent::__clone(); |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* Adds generic condition for filtering attributes |
|
166
|
|
|
* |
|
167
|
|
|
* @param string $operator Comparison operator, e.g. "==", "!=", "<", "<=", ">=", ">", "=~", "~=" |
|
168
|
|
|
* @param string $key Search key defined by the catalog manager, e.g. "catalog.status" |
|
169
|
|
|
* @param array|string $value Value or list of values to compare to |
|
170
|
|
|
* @return \Aimeos\Controller\Frontend\Catalog\Iface Catalog controller for fluent interface |
|
171
|
|
|
* @since 2019.04 |
|
172
|
|
|
*/ |
|
173
|
|
|
public function compare( string $operator, string $key, $value ) : Iface |
|
174
|
|
|
{ |
|
175
|
|
|
$this->addExpression( $this->filter->compare( $operator, $key, $value ) ); |
|
176
|
|
|
return $this; |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
|
|
180
|
|
|
/** |
|
181
|
|
|
* Returns the category for the given catalog code |
|
182
|
|
|
* |
|
183
|
|
|
* @param string $code Unique catalog code |
|
184
|
|
|
* @return \Aimeos\MShop\Catalog\Item\Iface Catalog item including the referenced domains items |
|
185
|
|
|
* @since 2019.04 |
|
186
|
|
|
*/ |
|
187
|
|
|
public function find( string $code ) : \Aimeos\MShop\Catalog\Item\Iface |
|
188
|
|
|
{ |
|
189
|
|
|
return $this->manager->find( $code, $this->domains, null, null, null ); |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* Creates a search function string for the given name and parameters |
|
195
|
|
|
* |
|
196
|
|
|
* @param string $name Name of the search function without parenthesis, e.g. "catalog:has" |
|
197
|
|
|
* @param array $params List of parameters for the search function with numeric keys starting at 0 |
|
198
|
|
|
* @return string Search function string that can be used in compare() |
|
199
|
|
|
*/ |
|
200
|
|
|
public function function( string $name, array $params ) : string |
|
201
|
|
|
{ |
|
202
|
|
|
return $this->filter->make( $name, $params ); |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
|
|
206
|
|
|
/** |
|
207
|
|
|
* Returns the category for the given catalog ID |
|
208
|
|
|
* |
|
209
|
|
|
* @param string $id Unique catalog ID |
|
210
|
|
|
* @return \Aimeos\MShop\Catalog\Item\Iface Catalog item including the referenced domains items |
|
211
|
|
|
* @since 2019.04 |
|
212
|
|
|
*/ |
|
213
|
|
|
public function get( string $id ) : \Aimeos\MShop\Catalog\Item\Iface |
|
214
|
|
|
{ |
|
215
|
|
|
return $this->manager->get( $id, $this->domains, null ); |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
|
|
219
|
|
|
/** |
|
220
|
|
|
* Returns the list of categories up to the root node including the node given by its ID |
|
221
|
|
|
* |
|
222
|
|
|
* @param string $id Current category ID |
|
223
|
|
|
* @return \Aimeos\MShop\Catalog\Item\Iface[] Associative list of categories |
|
224
|
|
|
* @since 2017.03 |
|
225
|
|
|
*/ |
|
226
|
|
|
public function getPath( string $id ) |
|
227
|
|
|
{ |
|
228
|
|
|
$list = $this->manager->getPath( $id, $this->domains ); |
|
229
|
|
|
|
|
230
|
|
|
if( $list->isAvailable()->search( false ) ) { |
|
231
|
|
|
throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Category is not available' ), 404 ); |
|
232
|
|
|
} |
|
233
|
|
|
|
|
234
|
|
|
if( $this->root ) |
|
235
|
|
|
{ |
|
236
|
|
|
foreach( $list as $key => $item ) |
|
237
|
|
|
{ |
|
238
|
|
|
if( $key == $this->root ) { |
|
239
|
|
|
break; |
|
240
|
|
|
} |
|
241
|
|
|
unset( $list[$key] ); |
|
242
|
|
|
} |
|
243
|
|
|
} |
|
244
|
|
|
|
|
245
|
|
|
return $list; |
|
246
|
|
|
} |
|
247
|
|
|
|
|
248
|
|
|
|
|
249
|
|
|
/** |
|
250
|
|
|
* Returns the categories filtered by the previously assigned conditions |
|
251
|
|
|
* |
|
252
|
|
|
* @param int $level Tree level constant, e.g. ONE, LIST or TREE |
|
253
|
|
|
* @return \Aimeos\MShop\Catalog\Item\Iface Category tree |
|
254
|
|
|
* @since 2019.04 |
|
255
|
|
|
*/ |
|
256
|
|
|
public function getTree( int $level = Iface::TREE ) : \Aimeos\MShop\Catalog\Item\Iface |
|
257
|
|
|
{ |
|
258
|
|
|
$this->addExpression( $this->filter->getConditions() ); |
|
259
|
|
|
$this->filter->add( $this->filter->and( $this->getConditions() ) ); |
|
260
|
|
|
|
|
261
|
|
|
return $this->manager->getTree( $this->root, $this->domains, $level, $this->filter ); |
|
262
|
|
|
} |
|
263
|
|
|
|
|
264
|
|
|
|
|
265
|
|
|
/** |
|
266
|
|
|
* Adds a filter to return only items containing a reference to the given ID |
|
267
|
|
|
* |
|
268
|
|
|
* @param string $domain Domain name of the referenced item, e.g. "media" |
|
269
|
|
|
* @param string|null $type Type code of the reference, e.g. "default" or null for all types |
|
270
|
|
|
* @param string|null $refId ID of the referenced item of the given domain or null for all references |
|
271
|
|
|
* @return \Aimeos\Controller\Frontend\Supplier\Iface Supplier controller for fluent interface |
|
272
|
|
|
* @since 2019.10 |
|
273
|
|
|
*/ |
|
274
|
|
|
public function has( string $domain, string $type = null, string $refId = null ) : Iface |
|
275
|
|
|
{ |
|
276
|
|
|
$params = [$domain]; |
|
277
|
|
|
!$type ?: $params[] = $type; |
|
278
|
|
|
!$refId ?: $params[] = $refId; |
|
279
|
|
|
|
|
280
|
|
|
$func = $this->filter->make( 'catalog:has', $params ); |
|
281
|
|
|
$this->addExpression( $this->filter->compare( '!=', $func, null ) ); |
|
282
|
|
|
return $this; |
|
283
|
|
|
} |
|
284
|
|
|
|
|
285
|
|
|
|
|
286
|
|
|
/** |
|
287
|
|
|
* Parses the given array and adds the conditions to the list of conditions |
|
288
|
|
|
* |
|
289
|
|
|
* @param array $conditions List of conditions, e.g. ['>' => ['catalog.status' => 0]] |
|
290
|
|
|
* @return \Aimeos\Controller\Frontend\Catalog\Iface Catalog controller for fluent interface |
|
291
|
|
|
* @since 2019.04 |
|
292
|
|
|
*/ |
|
293
|
|
|
public function parse( array $conditions ) : Iface |
|
294
|
|
|
{ |
|
295
|
|
|
if( ( $cond = $this->filter->parse( $conditions ) ) !== null ) { |
|
296
|
|
|
$this->addExpression( $cond ); |
|
297
|
|
|
} |
|
298
|
|
|
|
|
299
|
|
|
return $this; |
|
300
|
|
|
} |
|
301
|
|
|
|
|
302
|
|
|
|
|
303
|
|
|
/** |
|
304
|
|
|
* Returns the category for the given category URL name |
|
305
|
|
|
* |
|
306
|
|
|
* @param string $name category URL name |
|
307
|
|
|
* @return \Aimeos\MShop\Catalog\Item\Iface Catalog item including the referenced domains items |
|
308
|
|
|
* @since 2023.10 |
|
309
|
|
|
*/ |
|
310
|
|
|
public function resolve( string $name ) : \Aimeos\MShop\Catalog\Item\Iface |
|
311
|
|
|
{ |
|
312
|
|
|
$search = $this->manager->filter( null )->add( 'catalog.url', '==', $name )->slice( 0, 1 ); |
|
313
|
|
|
|
|
314
|
|
|
if( ( $item = $this->manager->search( $search, $this->domains )->first() ) === null ) |
|
315
|
|
|
{ |
|
316
|
|
|
$msg = $this->context()->translate( 'controller/frontend', 'Unable to find category "%1$s"' ); |
|
317
|
|
|
throw new \Aimeos\Controller\Frontend\Catalog\Exception( sprintf( $msg, $name ), 404 ); |
|
318
|
|
|
} |
|
319
|
|
|
|
|
320
|
|
|
return $item; |
|
321
|
|
|
} |
|
322
|
|
|
|
|
323
|
|
|
|
|
324
|
|
|
/** |
|
325
|
|
|
* Sets the catalog ID of node that is used as root node |
|
326
|
|
|
* |
|
327
|
|
|
* @param string|null $id Catalog ID |
|
328
|
|
|
* @return \Aimeos\Controller\Frontend\Catalog\Iface Catalog controller for fluent interface |
|
329
|
|
|
* @since 2019.04 |
|
330
|
|
|
*/ |
|
331
|
|
|
public function root( string $id = null ) : Iface |
|
332
|
|
|
{ |
|
333
|
|
|
$this->root = ( $id ? $id : null ); |
|
334
|
|
|
return $this; |
|
335
|
|
|
} |
|
336
|
|
|
|
|
337
|
|
|
|
|
338
|
|
|
/** |
|
339
|
|
|
* Returns the categories filtered by the previously assigned conditions |
|
340
|
|
|
* |
|
341
|
|
|
* @param int &$total Parameter where the total number of found categories will be stored in |
|
342
|
|
|
* @return \Aimeos\Map Ordered list of catalog items implementing \Aimeos\MShop\Catalog\Item\Iface |
|
343
|
|
|
* @since 2019.10 |
|
344
|
|
|
*/ |
|
345
|
|
|
public function search( int &$total = null ) : \Aimeos\Map |
|
346
|
|
|
{ |
|
347
|
|
|
$this->addExpression( $this->filter->getConditions() ); |
|
348
|
|
|
|
|
349
|
|
|
$this->filter->setConditions( $this->filter->and( $this->getConditions() ) ); |
|
350
|
|
|
$this->filter->setSortations( $this->getSortations() ); |
|
351
|
|
|
|
|
352
|
|
|
return $this->manager->search( $this->filter, $this->domains, $total ); |
|
353
|
|
|
} |
|
354
|
|
|
|
|
355
|
|
|
|
|
356
|
|
|
/** |
|
357
|
|
|
* Sets the start value and the number of returned products for slicing the list of found products |
|
358
|
|
|
* |
|
359
|
|
|
* @param int $start Start value of the first product in the list |
|
360
|
|
|
* @param int $limit Number of returned products |
|
361
|
|
|
* @return \Aimeos\Controller\Frontend\Catalog\Iface Catalog controller for fluent interface |
|
362
|
|
|
* @since 2019.10 |
|
363
|
|
|
*/ |
|
364
|
|
|
public function slice( int $start, int $limit ) : Iface |
|
365
|
|
|
{ |
|
366
|
|
|
$maxsize = $this->context()->config()->get( 'controller/frontend/common/max-size', 500 ); |
|
367
|
|
|
$this->filter->slice( $start, min( $limit, $maxsize ) ); |
|
368
|
|
|
return $this; |
|
369
|
|
|
} |
|
370
|
|
|
|
|
371
|
|
|
|
|
372
|
|
|
/** |
|
373
|
|
|
* Sets the sorting of the result list |
|
374
|
|
|
* |
|
375
|
|
|
* @param string|null $key Search key for sorting of the result list and null for no sorting |
|
376
|
|
|
* @return \Aimeos\Controller\Frontend\Catalog\Iface Catalog controller for fluent interface |
|
377
|
|
|
* @since 2019.10 |
|
378
|
|
|
*/ |
|
379
|
|
|
public function sort( ?string $key = null ) : Iface |
|
380
|
|
|
{ |
|
381
|
|
|
$list = $this->splitKeys( $key ); |
|
382
|
|
|
|
|
383
|
|
|
foreach( $list as $sortkey ) |
|
384
|
|
|
{ |
|
385
|
|
|
$direction = ( $sortkey[0] === '-' ? '-' : '+' ); |
|
386
|
|
|
$this->addExpression( $this->filter->sort( $direction, ltrim( $sortkey, '+-' ) ) ); |
|
387
|
|
|
} |
|
388
|
|
|
|
|
389
|
|
|
return $this; |
|
390
|
|
|
} |
|
391
|
|
|
|
|
392
|
|
|
|
|
393
|
|
|
/** |
|
394
|
|
|
* Sets the referenced domains that will be fetched too when retrieving items |
|
395
|
|
|
* |
|
396
|
|
|
* @param array $domains Domain names of the referenced items that should be fetched too |
|
397
|
|
|
* @return \Aimeos\Controller\Frontend\Catalog\Iface Catalog controller for fluent interface |
|
398
|
|
|
* @since 2019.04 |
|
399
|
|
|
*/ |
|
400
|
|
|
public function uses( array $domains ) : Iface |
|
401
|
|
|
{ |
|
402
|
|
|
$this->domains = $domains; |
|
403
|
|
|
return $this; |
|
404
|
|
|
} |
|
405
|
|
|
|
|
406
|
|
|
|
|
407
|
|
|
/** |
|
408
|
|
|
* Limits categories returned to only visible ones depending on the given category IDs |
|
409
|
|
|
* |
|
410
|
|
|
* @param array $catIds List of category IDs |
|
411
|
|
|
* @return \Aimeos\Controller\Frontend\Catalog\Iface Catalog controller for fluent interface |
|
412
|
|
|
*/ |
|
413
|
|
|
public function visible( array $catIds ) : Iface |
|
414
|
|
|
{ |
|
415
|
|
|
$expr = []; |
|
416
|
|
|
$config = $this->context()->config(); |
|
417
|
|
|
|
|
418
|
|
|
if( !empty( $catIds ) ) |
|
419
|
|
|
{ |
|
420
|
|
|
$expr[] = $this->filter->compare( '==', 'catalog.parentid', $catIds ); |
|
421
|
|
|
$expr[] = $this->filter->compare( '==', 'catalog.id', $catIds ); |
|
422
|
|
|
} |
|
423
|
|
|
|
|
424
|
|
|
/** controller/frontend/catalog/levels-always |
|
425
|
|
|
* The number of levels in the category tree that should be always displayed |
|
426
|
|
|
* |
|
427
|
|
|
* Usually, only the root node and the first level of the category |
|
428
|
|
|
* tree is shown in the frontend. Only if the user clicks on a |
|
429
|
|
|
* node in the first level, the page reloads and the sub-nodes of |
|
430
|
|
|
* the chosen category are rendered as well. |
|
431
|
|
|
* |
|
432
|
|
|
* Using this configuration option you can enforce the given number |
|
433
|
|
|
* of levels to be always displayed. The root node uses level 0, the |
|
434
|
|
|
* categories below level 1 and so on. |
|
435
|
|
|
* |
|
436
|
|
|
* In most cases you can set this value via the administration interface |
|
437
|
|
|
* of the shop application. In that case you often can configure the |
|
438
|
|
|
* levels individually for each catalog filter. |
|
439
|
|
|
* |
|
440
|
|
|
* Note: This setting was available between 2014.03 and 2019.04 as |
|
441
|
|
|
* client/html/catalog/filter/tree/levels-always |
|
442
|
|
|
* |
|
443
|
|
|
* @param integer Number of tree levels |
|
444
|
|
|
* @since 2019.04 |
|
445
|
|
|
* @category User |
|
446
|
|
|
* @category Developer |
|
447
|
|
|
* @see controller/frontend/catalog/levels-only |
|
448
|
|
|
*/ |
|
449
|
|
|
if( ( $levels = $config->get( 'controller/frontend/catalog/levels-always' ) ) != null ) { |
|
450
|
|
|
$expr[] = $this->filter->compare( '<=', 'catalog.level', $levels ); |
|
451
|
|
|
} |
|
452
|
|
|
|
|
453
|
|
|
/** controller/frontend/catalog/levels-only |
|
454
|
|
|
* No more than this number of levels in the category tree should be displayed |
|
455
|
|
|
* |
|
456
|
|
|
* If the user clicks on a category node, the page reloads and the |
|
457
|
|
|
* sub-nodes of the chosen category are rendered as well. |
|
458
|
|
|
* Using this configuration option you can enforce that no more than |
|
459
|
|
|
* the given number of levels will be displayed at all. The root |
|
460
|
|
|
* node uses level 0, the categories below level 1 and so on. |
|
461
|
|
|
* |
|
462
|
|
|
* In most cases you can set this value via the administration interface |
|
463
|
|
|
* of the shop application. In that case you often can configure the |
|
464
|
|
|
* levels individually for each catalog filter. |
|
465
|
|
|
* |
|
466
|
|
|
* Note: This setting was available between 2014.03 and 2019.04 as |
|
467
|
|
|
* client/html/catalog/filter/tree/levels-only |
|
468
|
|
|
* |
|
469
|
|
|
* @param integer Number of tree levels |
|
470
|
|
|
* @since 2014.03 |
|
471
|
|
|
* @category User |
|
472
|
|
|
* @category Developer |
|
473
|
|
|
* @see controller/frontend/catalog/levels-always |
|
474
|
|
|
*/ |
|
475
|
|
|
if( ( $levels = $config->get( 'controller/frontend/catalog/levels-only' ) ) != null ) { |
|
476
|
|
|
$this->addExpression( $this->filter->compare( '<=', 'catalog.level', $levels ) ); |
|
477
|
|
|
} |
|
478
|
|
|
|
|
479
|
|
|
$this->addExpression( $this->filter->or( $expr ) ); |
|
480
|
|
|
return $this; |
|
481
|
|
|
} |
|
482
|
|
|
|
|
483
|
|
|
|
|
484
|
|
|
/** |
|
485
|
|
|
* Returns the manager used by the controller |
|
486
|
|
|
* |
|
487
|
|
|
* @return \Aimeos\MShop\Common\Manager\Iface Manager object |
|
488
|
|
|
*/ |
|
489
|
|
|
protected function getManager() : \Aimeos\MShop\Common\Manager\Iface |
|
490
|
|
|
{ |
|
491
|
|
|
return $this->manager; |
|
492
|
|
|
} |
|
493
|
|
|
} |
|
494
|
|
|
|