1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2022 |
6
|
|
|
* @package Client |
7
|
|
|
* @subpackage Html |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Client\Html\Catalog\Lists; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Default implementation of catalog list section HTML clients. |
16
|
|
|
* |
17
|
|
|
* @package Client |
18
|
|
|
* @subpackage Html |
19
|
|
|
*/ |
20
|
|
|
class Standard |
21
|
|
|
extends \Aimeos\Client\Html\Catalog\Base |
22
|
|
|
implements \Aimeos\Client\Html\Common\Client\Factory\Iface |
23
|
|
|
{ |
24
|
|
|
private $tags = []; |
25
|
|
|
private $expire; |
26
|
|
|
private $view; |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Returns the HTML code for insertion into the body. |
31
|
|
|
* |
32
|
|
|
* @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
33
|
|
|
* @return string HTML code |
34
|
|
|
*/ |
35
|
|
|
public function body( string $uid = '' ) : string |
36
|
|
|
{ |
37
|
|
|
$view = $this->view(); |
38
|
|
|
$prefixes = ['f_catid', 'f_supid', 'f_sort', 'l_page', 'l_type']; |
39
|
|
|
|
40
|
|
|
/** client/html/catalog/lists/cache |
41
|
|
|
* Enables or disables caching only for the catalog lists component |
42
|
|
|
* |
43
|
|
|
* Disable caching for components can be useful if you would have too much |
44
|
|
|
* entries to cache or if the component contains non-cacheable parts that |
45
|
|
|
* can't be replaced using the modify() method. |
46
|
|
|
* |
47
|
|
|
* @param boolean True to enable caching, false to disable |
48
|
|
|
* @see client/html/catalog/detail/cache |
49
|
|
|
* @see client/html/catalog/filter/cache |
50
|
|
|
* @see client/html/catalog/stage/cache |
51
|
|
|
*/ |
52
|
|
|
|
53
|
|
|
/** client/html/catalog/lists |
54
|
|
|
* All parameters defined for the catalog list component and its subparts |
55
|
|
|
* |
56
|
|
|
* This returns all settings related to the filter component. |
57
|
|
|
* Please refer to the single settings for details. |
58
|
|
|
* |
59
|
|
|
* @param array Associative list of name/value settings |
60
|
|
|
* @see client/html/catalog#list |
61
|
|
|
*/ |
62
|
|
|
$confkey = 'client/html/catalog/lists'; |
63
|
|
|
|
64
|
|
|
$args = map( $view->param() )->except( $prefixes )->filter( function( $val, $key ) { |
65
|
|
|
return !strncmp( $key, 'f_', 2 ) || !strncmp( $key, 'l_', 2 ); |
66
|
|
|
} ); |
67
|
|
|
|
68
|
|
|
if( $args->isEmpty() && ( $html = $this->cached( 'body', $uid, $prefixes, $confkey ) ) !== null ) { |
69
|
|
|
return $this->modify( $html, $uid ); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** client/html/catalog/lists/template-body |
73
|
|
|
* Relative path to the HTML body template of the catalog list client. |
74
|
|
|
* |
75
|
|
|
* The template file contains the HTML code and processing instructions |
76
|
|
|
* to generate the result shown in the body of the frontend. The |
77
|
|
|
* configuration string is the path to the template file relative |
78
|
|
|
* to the templates directory (usually in client/html/templates). |
79
|
|
|
* |
80
|
|
|
* You can overwrite the template file configuration in extensions and |
81
|
|
|
* provide alternative templates. These alternative templates should be |
82
|
|
|
* named like the default one but suffixed by |
83
|
|
|
* an unique name. You may use the name of your project for this. If |
84
|
|
|
* you've implemented an alternative client class as well, it |
85
|
|
|
* should be suffixed by the name of the new class. |
86
|
|
|
* |
87
|
|
|
* It's also possible to create a specific template for each type, e.g. |
88
|
|
|
* for the grid, list or whatever view you want to offer your users. In |
89
|
|
|
* that case, you can configure the template by adding "-<type>" to the |
90
|
|
|
* configuration key. To configure an alternative list view template for |
91
|
|
|
* example, use the key |
92
|
|
|
* |
93
|
|
|
* client/html/catalog/lists/template-body-list = catalog/lists/body-list.php |
94
|
|
|
* |
95
|
|
|
* The argument is the relative path to the new template file. The type of |
96
|
|
|
* the view is determined by the "l_type" parameter (allowed characters for |
97
|
|
|
* the types are a-z and 0-9). The catalog list type subpart |
98
|
|
|
* contains the template for switching between list types. |
99
|
|
|
* |
100
|
|
|
* @param string Relative path to the template creating code for the HTML page body |
101
|
|
|
* @since 2014.03 |
102
|
|
|
* @see client/html/catalog/lists/template-header |
103
|
|
|
* @see client/html/catalog/lists/type/template-body |
104
|
|
|
*/ |
105
|
|
|
$template = $this->context()->config()->get( 'client/html/catalog/lists/template-body', 'catalog/lists/body' ); |
106
|
|
|
|
107
|
|
|
$view = $this->view = $this->view ?? $this->object()->data( $view, $this->tags, $this->expire ); |
108
|
|
|
$html = $this->modify( $view->render( $template ), $uid ); |
109
|
|
|
|
110
|
|
|
if( $args->isEmpty() ) { |
111
|
|
|
return $this->cache( 'body', $uid, $prefixes, $confkey, $html, $this->tags, $this->expire ); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
return $html; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Returns the HTML string for insertion into the header. |
120
|
|
|
* |
121
|
|
|
* @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
122
|
|
|
* @return string|null String including HTML tags for the header on error |
123
|
|
|
*/ |
124
|
|
|
public function header( string $uid = '' ) : ?string |
125
|
|
|
{ |
126
|
|
|
$view = $this->view(); |
127
|
|
|
$confkey = 'client/html/catalog/lists'; |
128
|
|
|
$prefixes = ['f_catid', 'f_supid', 'f_sort', 'l_page', 'l_type']; |
129
|
|
|
|
130
|
|
|
$args = map( $view->param() )->except( $prefixes )->filter( function( $val, $key ) { |
131
|
|
|
return !strncmp( $key, 'f_', 2 ) || !strncmp( $key, 'l_', 2 ); |
132
|
|
|
} ); |
133
|
|
|
|
134
|
|
|
if( $args->isEmpty() && ( $html = $this->cached( 'header', $uid, $prefixes, $confkey ) ) !== null ) { |
135
|
|
|
return $this->modify( $html, $uid ); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** client/html/catalog/lists/template-header |
139
|
|
|
* Relative path to the HTML header template of the catalog list client. |
140
|
|
|
* |
141
|
|
|
* The template file contains the HTML code and processing instructions |
142
|
|
|
* to generate the HTML code that is inserted into the HTML page header |
143
|
|
|
* of the rendered page in the frontend. The configuration string is the |
144
|
|
|
* path to the template file relative to the templates directory (usually |
145
|
|
|
* in client/html/templates). |
146
|
|
|
* |
147
|
|
|
* You can overwrite the template file configuration in extensions and |
148
|
|
|
* provide alternative templates. These alternative templates should be |
149
|
|
|
* named like the default one but suffixed by |
150
|
|
|
* an unique name. You may use the name of your project for this. If |
151
|
|
|
* you've implemented an alternative client class as well, it |
152
|
|
|
* should be suffixed by the name of the new class. |
153
|
|
|
* |
154
|
|
|
* It's also possible to create a specific template for each type, e.g. |
155
|
|
|
* for the grid, list or whatever view you want to offer your users. In |
156
|
|
|
* that case, you can configure the template by adding "-<type>" to the |
157
|
|
|
* configuration key. To configure an alternative list view template for |
158
|
|
|
* example, use the key |
159
|
|
|
* |
160
|
|
|
* client/html/catalog/lists/template-header-list = catalog/lists/header-list.php |
161
|
|
|
* |
162
|
|
|
* The argument is the relative path to the new template file. The type of |
163
|
|
|
* the view is determined by the "l_type" parameter (allowed characters for |
164
|
|
|
* the types are a-z and 0-9). The catalog list type subpart |
165
|
|
|
* contains the template for switching between list types. |
166
|
|
|
* |
167
|
|
|
* @param string Relative path to the template creating code for the HTML page head |
168
|
|
|
* @since 2014.03 |
169
|
|
|
* @see client/html/catalog/lists/template-body |
170
|
|
|
* @see client/html/catalog/lists/type/template-body |
171
|
|
|
*/ |
172
|
|
|
$template = $this->context()->config()->get( 'client/html/catalog/lists/template-header', 'catalog/lists/header' ); |
173
|
|
|
|
174
|
|
|
$view = $this->view = $this->view ?? $this->object()->data( $view, $this->tags, $this->expire ); |
175
|
|
|
$html = $this->modify( $view->render( $template ), $uid ); |
176
|
|
|
|
177
|
|
|
if( $args->isEmpty() ) { |
178
|
|
|
return $this->cache( 'header', $uid, $prefixes, $confkey, $html, $this->tags, $this->expire ); |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
return $html; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* Processes the input, e.g. store given values. |
187
|
|
|
* |
188
|
|
|
* A view must be available and this method doesn't generate any output |
189
|
|
|
* besides setting view variables if necessary. |
190
|
|
|
*/ |
191
|
|
|
public function init() |
192
|
|
|
{ |
193
|
|
|
$view = $this->view(); |
194
|
|
|
$context = $this->context(); |
195
|
|
|
|
196
|
|
|
$site = $context->locale()->getSiteItem()->getCode(); |
197
|
|
|
$params = $this->getClientParams( $view->param() ); |
198
|
|
|
|
199
|
|
|
$catId = $context->config()->get( 'client/html/catalog/lists/catid-default' ); |
200
|
|
|
|
201
|
|
|
if( ( $catId = $view->param( 'f_catid', $catId ) ) ) |
202
|
|
|
{ |
203
|
|
|
$params['f_name'] = $view->param( 'f_name' ); |
204
|
|
|
$params['f_catid'] = $catId; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
$context->session()->set( 'aimeos/catalog/lists/params/last/' . $site, $params ); |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* Sets the necessary parameter values in the view. |
213
|
|
|
* |
214
|
|
|
* @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output |
215
|
|
|
* @param array &$tags Result array for the list of tags that are associated to the output |
216
|
|
|
* @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
217
|
|
|
* @return \Aimeos\MW\View\Iface Modified view object |
218
|
|
|
*/ |
219
|
|
|
public function data( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface |
220
|
|
|
{ |
221
|
|
|
$total = 0; |
222
|
|
|
$sort = $this->sort(); |
223
|
|
|
$size = $this->size(); |
224
|
|
|
$pages = $this->pages(); |
225
|
|
|
$context = $this->context(); |
226
|
|
|
$page = min( max( $view->param( 'l_page', 1 ), 1 ), $pages ); |
227
|
|
|
|
228
|
|
|
if( !empty( $catIds = $this->categories() ) ) |
229
|
|
|
{ |
230
|
|
|
$listCatPath = \Aimeos\Controller\Frontend::create( $context, 'catalog' ) |
231
|
|
|
->uses( ['media', 'media/property', 'text'] ) |
232
|
|
|
->getPath( current( $catIds ) ); |
233
|
|
|
|
234
|
|
|
$view->listCatPath = $this->addMetaItems( $listCatPath, $expire, $tags ); |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
$cntl = \Aimeos\Controller\Frontend::create( $context, 'product' ) |
238
|
|
|
->sort( $sort ) // prioritize user sorting over the sorting through relevance and category |
239
|
|
|
->text( $view->param( 'f_search' ) ) |
240
|
|
|
->price( $view->param( 'f_price' ) ) |
241
|
|
|
->category( $catIds, 'default', $this->level() ) |
242
|
|
|
->supplier( $this->suppliers() ) |
243
|
|
|
->allOf( $this->attributes() ) |
244
|
|
|
->allOf( $view->param( 'f_attrid', [] ) ) |
245
|
|
|
->oneOf( $view->param( 'f_optid', [] ) ) |
246
|
|
|
->oneOf( $view->param( 'f_oneid', [] ) ) |
247
|
|
|
->slice( ( $page - 1 ) * $size, $size ) |
248
|
|
|
->uses( $this->domains() ); |
249
|
|
|
|
250
|
|
|
if( $this->inStock() ) { |
251
|
|
|
$cntl->compare( '>', 'product.instock', 0 ); |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
$products = $cntl->search( $total ); |
255
|
|
|
$articles = $products->getRefItems( 'product', 'default', 'default' )->flat( 1 )->union( $products ); |
256
|
|
|
|
257
|
|
|
// Delete cache when products are added or deleted even when in "tag-all" mode |
258
|
|
|
$this->addMetaItems( $articles, $expire, $tags, ['product'] ); |
259
|
|
|
|
260
|
|
|
|
261
|
|
|
$view->listProductItems = $products; |
262
|
|
|
$view->listProductSort = $sort; |
263
|
|
|
$view->listProductTotal = $total; |
264
|
|
|
|
265
|
|
|
$view->listPageSize = $size; |
266
|
|
|
$view->listPageCurr = $page; |
267
|
|
|
$view->listPagePrev = ( $page > 1 ? $page - 1 : 1 ); |
268
|
|
|
$view->listPageLast = ( $total != 0 ? min( ceil( $total / $size ), $pages ) : 1 ); |
|
|
|
|
269
|
|
|
$view->listPageNext = ( $page < $view->listPageLast ? $page + 1 : $view->listPageLast ); |
270
|
|
|
|
271
|
|
|
$view->listParams = $this->getClientParams( map( $view->param() )->toArray() ); |
272
|
|
|
$view->listStockUrl = $this->stockUrl( $articles ); |
273
|
|
|
$view->listPosition = ( $page - 1 ) * $size; |
274
|
|
|
|
275
|
|
|
if( !empty( $type = $view->param( 'l_type' ) ) && ctype_alnum( $type ) ) { |
276
|
|
|
return $view->set( 'listPartial', 'catalog/lists/items-' . $type ); |
277
|
|
|
} |
278
|
|
|
|
279
|
|
|
return parent::data( $view, $tags, $expire ); |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
|
283
|
|
|
/** |
284
|
|
|
* Modifies the cached content to replace content based on sessions or cookies. |
285
|
|
|
* |
286
|
|
|
* @param string $content Cached content |
287
|
|
|
* @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
288
|
|
|
* @return string Modified content |
289
|
|
|
*/ |
290
|
|
|
public function modify( string $content, string $uid ) : string |
291
|
|
|
{ |
292
|
|
|
return $this->replaceSection( $content, $this->view()->csrf()->formfield(), 'catalog.lists.csrf' ); |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
|
296
|
|
|
/** |
297
|
|
|
* Returns the attribute IDs used for filtering products |
298
|
|
|
* |
299
|
|
|
* @return array List of attribute IDs |
300
|
|
|
*/ |
301
|
|
|
protected function attributes() : array |
302
|
|
|
{ |
303
|
|
|
/** client/html/catalog/lists/attrid-default |
304
|
|
|
* Additional attribute IDs used to limit search results |
305
|
|
|
* |
306
|
|
|
* Using this setting, products result lists can be limited by additional |
307
|
|
|
* attributes. Then, only products which have associated the configured |
308
|
|
|
* attribute IDs will be returned and shown in the frontend. The value |
309
|
|
|
* can be either a single attribute ID or a list of attribute IDs. |
310
|
|
|
* |
311
|
|
|
* @param array|string Attribute ID or IDs |
312
|
|
|
* @since 2021.10 |
313
|
|
|
* @see client/html/catalog/lists/sort |
314
|
|
|
* @see client/html/catalog/lists/size |
315
|
|
|
* @see client/html/catalog/lists/domains |
316
|
|
|
* @see client/html/catalog/lists/levels |
317
|
|
|
* @see client/html/catalog/lists/instock |
318
|
|
|
* @see client/html/catalog/lists/catid-default |
319
|
|
|
* @see client/html/catalog/lists/supid-default |
320
|
|
|
* @see client/html/catalog/detail/prodid-default |
321
|
|
|
*/ |
322
|
|
|
$attrids = $this->context()->config()->get( 'client/html/catalog/lists/attrid-default' ); |
323
|
|
|
$attrids = $attrids != null && is_scalar( $attrids ) ? explode( ',', $attrids ) : $attrids; // workaround for TYPO3 |
324
|
|
|
|
325
|
|
|
return (array) $attrids; |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
|
329
|
|
|
/** |
330
|
|
|
* Returns the category IDs used for filtering products |
331
|
|
|
* |
332
|
|
|
* @return array List of category IDs |
333
|
|
|
*/ |
334
|
|
|
protected function categories() : array |
335
|
|
|
{ |
336
|
|
|
$context = $this->context(); |
|
|
|
|
337
|
|
|
$config = $this->context()->config(); |
|
|
|
|
338
|
|
|
|
339
|
|
|
/** client/html/catalog/lists/catid-default |
340
|
|
|
* The default category ID used if none is given as parameter |
341
|
|
|
* |
342
|
|
|
* If users view a product list page without a category ID in the |
343
|
|
|
* parameter list, the first found products are displayed with a |
344
|
|
|
* random order. You can circumvent this by configuring a default |
345
|
|
|
* category ID that should be used in this case (the ID of the root |
346
|
|
|
* category is best for this). In most cases you can set this value |
347
|
|
|
* via the administration interface of the shop application. |
348
|
|
|
* |
349
|
|
|
* @param array|string Category ID or IDs |
350
|
|
|
* @since 2014.03 |
351
|
|
|
* @see client/html/catalog/lists/sort |
352
|
|
|
* @see client/html/catalog/lists/size |
353
|
|
|
* @see client/html/catalog/lists/domains |
354
|
|
|
* @see client/html/catalog/lists/levels |
355
|
|
|
* @see client/html/catalog/lists/attrid-default |
356
|
|
|
* @see client/html/catalog/detail/prodid-default |
357
|
|
|
* @see client/html/catalog/lists/supid-default |
358
|
|
|
* @see client/html/catalog/lists/instock |
359
|
|
|
*/ |
360
|
|
|
$catids = $this->view()->param( 'f_catid', $this->context()->config()->get( 'client/html/catalog/lists/catid-default' ) ); |
361
|
|
|
$catids = $catids != null && is_scalar( $catids ) ? explode( ',', $catids ) : $catids; // workaround for TYPO3 |
362
|
|
|
|
363
|
|
|
return (array) $catids; |
364
|
|
|
} |
365
|
|
|
|
366
|
|
|
|
367
|
|
|
/** |
368
|
|
|
* Returns the data domains fetched along with the products |
369
|
|
|
* |
370
|
|
|
* @return array List of domain names |
371
|
|
|
*/ |
372
|
|
|
protected function domains() : array |
373
|
|
|
{ |
374
|
|
|
$config = $this->context()->config(); |
375
|
|
|
|
376
|
|
|
/** client/html/catalog/domains |
377
|
|
|
* A list of domain names whose items should be available in the catalog view templates |
378
|
|
|
* |
379
|
|
|
* The templates rendering catalog related data usually add the images and |
380
|
|
|
* texts associated to each item. If you want to display additional |
381
|
|
|
* content like the attributes, you can configure your own list of |
382
|
|
|
* domains (attribute, media, price, product, text, etc. are domains) |
383
|
|
|
* whose items are fetched from the storage. Please keep in mind that |
384
|
|
|
* the more domains you add to the configuration, the more time is required |
385
|
|
|
* for fetching the content! |
386
|
|
|
* |
387
|
|
|
* This configuration option can be overwritten by the "client/html/catalog/lists/domains" |
388
|
|
|
* configuration option that allows to configure the domain names of the |
389
|
|
|
* items fetched specifically for all types of product listings. |
390
|
|
|
* |
391
|
|
|
* @param array List of domain names |
392
|
|
|
* @since 2014.03 |
393
|
|
|
* @see client/html/catalog/lists/domains |
394
|
|
|
* @see client/html/catalog/lists/size |
395
|
|
|
* @see client/html/catalog/lists/levels |
396
|
|
|
* @see client/html/catalog/lists/sort |
397
|
|
|
* @see client/html/catalog/lists/pages |
398
|
|
|
*/ |
399
|
|
|
$domains = $config->get( 'client/html/catalog/domains', ['media', 'media/property', 'price', 'text'] ); |
400
|
|
|
|
401
|
|
|
/** client/html/catalog/lists/domains |
402
|
|
|
* A list of domain names whose items should be available in the product list view template |
403
|
|
|
* |
404
|
|
|
* The templates rendering product lists usually add the images, prices |
405
|
|
|
* and texts associated to each product item. If you want to display additional |
406
|
|
|
* content like the product attributes, you can configure your own list of |
407
|
|
|
* domains (attribute, media, price, product, text, etc. are domains) |
408
|
|
|
* whose items are fetched from the storage. Please keep in mind that |
409
|
|
|
* the more domains you add to the configuration, the more time is required |
410
|
|
|
* for fetching the content! |
411
|
|
|
* |
412
|
|
|
* This configuration option overwrites the "client/html/catalog/domains" |
413
|
|
|
* option that allows to configure the domain names of the items fetched |
414
|
|
|
* for all catalog related data. |
415
|
|
|
* |
416
|
|
|
* @param array List of domain names |
417
|
|
|
* @since 2014.03 |
418
|
|
|
* @see client/html/catalog/domains |
419
|
|
|
* @see client/html/catalog/detail/domains |
420
|
|
|
* @see client/html/catalog/stage/domains |
421
|
|
|
* @see client/html/catalog/lists/attrid-default |
422
|
|
|
* @see client/html/catalog/lists/catid-default |
423
|
|
|
* @see client/html/catalog/lists/supid-default |
424
|
|
|
* @see client/html/catalog/lists/size |
425
|
|
|
* @see client/html/catalog/lists/levels |
426
|
|
|
* @see client/html/catalog/lists/sort |
427
|
|
|
* @see client/html/catalog/lists/pages |
428
|
|
|
* @see client/html/catalog/lists/instock |
429
|
|
|
*/ |
430
|
|
|
$domains = $config->get( 'client/html/catalog/lists/domains', $domains ); |
431
|
|
|
|
432
|
|
|
if( $config->get( 'client/html/catalog/lists/basket-add', false ) ) { |
433
|
|
|
$domains = array_merge_recursive( $domains, ['product' => ['default'], 'attribute' => ['variant', 'custom', 'config']] ); |
434
|
|
|
} |
435
|
|
|
|
436
|
|
|
return $domains; |
437
|
|
|
} |
438
|
|
|
|
439
|
|
|
|
440
|
|
|
/** |
441
|
|
|
* If all shown products must be in stock |
442
|
|
|
* |
443
|
|
|
* @return bool TRUE if all products must be in stock, FALSE if not |
444
|
|
|
*/ |
445
|
|
|
protected function inStock() : bool |
446
|
|
|
{ |
447
|
|
|
/** client/html/catalog/lists/instock |
448
|
|
|
* Show only products which are in stock |
449
|
|
|
* |
450
|
|
|
* This configuration option overwrites the "client/html/catalog/domains" |
451
|
|
|
* option that allows to configure the domain names of the items fetched |
452
|
|
|
* for all catalog related data. |
453
|
|
|
* |
454
|
|
|
* @param int Zero to show all products, "1" to show only products with stock |
455
|
|
|
* @since 2021.10 |
456
|
|
|
* @see client/html/catalog/domains |
457
|
|
|
* @see client/html/catalog/lists/domains |
458
|
|
|
* @see client/html/catalog/detail/domains |
459
|
|
|
* @see client/html/catalog/stage/domains |
460
|
|
|
* @see client/html/catalog/lists/attrid-default |
461
|
|
|
* @see client/html/catalog/lists/catid-default |
462
|
|
|
* @see client/html/catalog/lists/supid-default |
463
|
|
|
* @see client/html/catalog/lists/size |
464
|
|
|
* @see client/html/catalog/lists/levels |
465
|
|
|
* @see client/html/catalog/lists/sort |
466
|
|
|
* @see client/html/catalog/lists/pages |
467
|
|
|
*/ |
468
|
|
|
return (bool) $this->context()->config()->get( 'client/html/catalog/lists/instock', false ); |
469
|
|
|
} |
470
|
|
|
|
471
|
|
|
|
472
|
|
|
/** |
473
|
|
|
* Returns the category depth level |
474
|
|
|
* |
475
|
|
|
* @return int Category depth level |
476
|
|
|
*/ |
477
|
|
|
protected function level() : int |
478
|
|
|
{ |
479
|
|
|
/** client/html/catalog/lists/levels |
480
|
|
|
* Include products of sub-categories in the product list of the current category |
481
|
|
|
* |
482
|
|
|
* Sometimes it may be useful to show products of sub-categories in the |
483
|
|
|
* current category product list, e.g. if the current category contains |
484
|
|
|
* no products at all or if there are only a few products in all categories. |
485
|
|
|
* |
486
|
|
|
* Possible constant values for this setting are: |
487
|
|
|
* |
488
|
|
|
* * 1 : Only products from the current category |
489
|
|
|
* * 2 : Products from the current category and the direct child categories |
490
|
|
|
* * 3 : Products from the current category and the whole category sub-tree |
491
|
|
|
* |
492
|
|
|
* Caution: Please keep in mind that displaying products of sub-categories |
493
|
|
|
* can slow down your shop, especially if it contains more than a few |
494
|
|
|
* products! You have no real control over the positions of the products |
495
|
|
|
* in the result list too because all products from different categories |
496
|
|
|
* with the same position value are placed randomly. |
497
|
|
|
* |
498
|
|
|
* Usually, a better way is to associate products to all categories they |
499
|
|
|
* should be listed in. This can be done manually if there are only a few |
500
|
|
|
* ones or during the product import automatically. |
501
|
|
|
* |
502
|
|
|
* @param integer Tree level constant |
503
|
|
|
* @since 2015.11 |
504
|
|
|
* @see client/html/catalog/lists/attrid-default |
505
|
|
|
* @see client/html/catalog/lists/catid-default |
506
|
|
|
* @see client/html/catalog/lists/supid-default |
507
|
|
|
* @see client/html/catalog/lists/domains |
508
|
|
|
* @see client/html/catalog/lists/size |
509
|
|
|
* @see client/html/catalog/lists/sort |
510
|
|
|
* @see client/html/catalog/lists/pages |
511
|
|
|
* @see client/html/catalog/lists/instock |
512
|
|
|
*/ |
513
|
|
|
return $this->context()->config()->get( 'client/html/catalog/lists/levels', \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ); |
514
|
|
|
} |
515
|
|
|
|
516
|
|
|
|
517
|
|
|
/** |
518
|
|
|
* Returns the number of allowed pages |
519
|
|
|
* |
520
|
|
|
* @return int Number of allowed pages |
521
|
|
|
*/ |
522
|
|
|
protected function pages() : int |
523
|
|
|
{ |
524
|
|
|
/** client/html/catalog/lists/pages |
525
|
|
|
* Maximum number of product pages shown in pagination |
526
|
|
|
* |
527
|
|
|
* Limits the number of product pages that are shown in the navigation. |
528
|
|
|
* The user is able to move to the next page (or previous one if it's not |
529
|
|
|
* the first) to display the next (or previous) products. |
530
|
|
|
* |
531
|
|
|
* The value must be a positive integer number. Negative values are not |
532
|
|
|
* allowed. The value can't be overwritten per request. |
533
|
|
|
* |
534
|
|
|
* @param integer Number of pages |
535
|
|
|
* @since 2019.04 |
536
|
|
|
* @see client/html/catalog/lists/attrid-default |
537
|
|
|
* @see client/html/catalog/lists/catid-default |
538
|
|
|
* @see client/html/catalog/lists/supid-default |
539
|
|
|
* @see client/html/catalog/lists/domains |
540
|
|
|
* @see client/html/catalog/lists/levels |
541
|
|
|
* @see client/html/catalog/lists/sort |
542
|
|
|
* @see client/html/catalog/lists/size |
543
|
|
|
* @see client/html/catalog/lists/instock |
544
|
|
|
*/ |
545
|
|
|
return $this->context()->config()->get( 'client/html/catalog/lists/pages', 100 ); |
546
|
|
|
} |
547
|
|
|
|
548
|
|
|
|
549
|
|
|
/** |
550
|
|
|
* Returns the maximum products per page |
551
|
|
|
* |
552
|
|
|
* @return int Maximum products per page |
553
|
|
|
*/ |
554
|
|
|
protected function size() : int |
555
|
|
|
{ |
556
|
|
|
/** client/html/catalog/lists/size |
557
|
|
|
* The number of products shown in a list page |
558
|
|
|
* |
559
|
|
|
* Limits the number of products that are shown in the list pages to the |
560
|
|
|
* given value. If more products are available, the products are split |
561
|
|
|
* into bunches which will be shown on their own list page. The user is |
562
|
|
|
* able to move to the next page (or previous one if it's not the first) |
563
|
|
|
* to display the next (or previous) products. |
564
|
|
|
* |
565
|
|
|
* The value must be an integer number from 1 to 100. Negative values as |
566
|
|
|
* well as values above 100 are not allowed. The value can be overwritten |
567
|
|
|
* per request if the "l_size" parameter is part of the URL. |
568
|
|
|
* |
569
|
|
|
* @param integer Number of products |
570
|
|
|
* @since 2014.03 |
571
|
|
|
* @see client/html/catalog/lists/attrid-default |
572
|
|
|
* @see client/html/catalog/lists/catid-default |
573
|
|
|
* @see client/html/catalog/lists/supid-default |
574
|
|
|
* @see client/html/catalog/lists/domains |
575
|
|
|
* @see client/html/catalog/lists/levels |
576
|
|
|
* @see client/html/catalog/lists/sort |
577
|
|
|
* @see client/html/catalog/lists/pages |
578
|
|
|
* @see client/html/catalog/lists/instock |
579
|
|
|
*/ |
580
|
|
|
$size = $this->context()->config()->get( 'client/html/catalog/lists/size', 48 ); |
581
|
|
|
|
582
|
|
|
return min( max( $this->view()->param( 'l_size', $size ), 1 ), 100 ); |
583
|
|
|
} |
584
|
|
|
|
585
|
|
|
|
586
|
|
|
/** |
587
|
|
|
* Returns the product sorting |
588
|
|
|
* |
589
|
|
|
* @return string Product sorting |
590
|
|
|
*/ |
591
|
|
|
protected function sort() : string |
592
|
|
|
{ |
593
|
|
|
/** client/html/catalog/lists/sort |
594
|
|
|
* Default sorting of product list if no other sorting is given by parameter |
595
|
|
|
* |
596
|
|
|
* Configures the standard sorting of products in list views. This sorting is used |
597
|
|
|
* as long as it's not overwritten by an URL parameter. Except "relevance", all |
598
|
|
|
* other sort codes can be prefixed by a "-" (minus) sign to sort the products in |
599
|
|
|
* a descending order. By default, the sorting is ascending. |
600
|
|
|
* |
601
|
|
|
* @param string Sort code "relevance", "name", "-name", "price", "-price", "ctime" or "-ctime" |
602
|
|
|
* @since 2018.07 |
603
|
|
|
* @see client/html/catalog/lists/attrid-default |
604
|
|
|
* @see client/html/catalog/lists/catid-default |
605
|
|
|
* @see client/html/catalog/lists/supid-default |
606
|
|
|
* @see client/html/catalog/lists/domains |
607
|
|
|
* @see client/html/catalog/lists/levels |
608
|
|
|
* @see client/html/catalog/lists/size |
609
|
|
|
* @see client/html/catalog/lists/instock |
610
|
|
|
*/ |
611
|
|
|
return $this->view()->param( 'f_sort', $this->context()->config()->get( 'client/html/catalog/lists/sort', 'relevance' ) ); |
612
|
|
|
} |
613
|
|
|
|
614
|
|
|
|
615
|
|
|
/** |
616
|
|
|
* Returns the supplier IDs used for filtering products |
617
|
|
|
* |
618
|
|
|
* @return List of supplier IDs |
|
|
|
|
619
|
|
|
*/ |
620
|
|
|
protected function suppliers() : array |
621
|
|
|
{ |
622
|
|
|
/** client/html/catalog/lists/supid-default |
623
|
|
|
* The default supplier ID used if none is given as parameter |
624
|
|
|
* |
625
|
|
|
* Products in the list page can be limited to one or more suppliers. |
626
|
|
|
* By default, the products are not limited to any supplier until one or |
627
|
|
|
* more supplier IDs are passed in the URL using the f_supid parameter. |
628
|
|
|
* You can also configure the default supplier IDs for limiting the |
629
|
|
|
* products if no IDs are passed in the URL using this configuration. |
630
|
|
|
* |
631
|
|
|
* @param array|string Supplier ID or IDs |
632
|
|
|
* @since 2021.01 |
633
|
|
|
* @see client/html/catalog/lists/sort |
634
|
|
|
* @see client/html/catalog/lists/size |
635
|
|
|
* @see client/html/catalog/lists/domains |
636
|
|
|
* @see client/html/catalog/lists/levels |
637
|
|
|
* @see client/html/catalog/lists/attrid-default |
638
|
|
|
* @see client/html/catalog/lists/catid-default |
639
|
|
|
* @see client/html/catalog/detail/prodid-default |
640
|
|
|
* @see client/html/catalog/lists/instock |
641
|
|
|
*/ |
642
|
|
|
$supids = $this->view()->param( 'f_supid', $this->context()->config()->get( 'client/html/catalog/lists/supid-default' ) ); |
643
|
|
|
$supids = $supids != null && is_scalar( $supids ) ? explode( ',', $supids ) : $supids; // workaround for TYPO3 |
644
|
|
|
|
645
|
|
|
return (array) $supids; |
646
|
|
|
} |
647
|
|
|
|
648
|
|
|
|
649
|
|
|
protected function stockUrl( \Aimeos\Map $products ) : \Aimeos\Map |
650
|
|
|
{ |
651
|
|
|
/** client/html/catalog/lists/stock |
652
|
|
|
* Enables or disables displaying product stock levels in product list views |
653
|
|
|
* |
654
|
|
|
* This configuration option allows shop owners to display product |
655
|
|
|
* stock levels for each product in list views or to disable |
656
|
|
|
* fetching product stock information. |
657
|
|
|
* |
658
|
|
|
* The stock information is fetched via AJAX and inserted via Javascript. |
659
|
|
|
* This allows to cache product items by leaving out such highly |
660
|
|
|
* dynamic content like stock levels which changes with each order. |
661
|
|
|
* |
662
|
|
|
* @param boolean Value of "1" to display stock levels, "0" to disable displaying them |
663
|
|
|
* @since 2014.03 |
664
|
|
|
* @see client/html/catalog/detail/stock/enable |
665
|
|
|
* @see client/html/catalog/stock/url/target |
666
|
|
|
* @see client/html/catalog/stock/url/controller |
667
|
|
|
* @see client/html/catalog/stock/url/action |
668
|
|
|
* @see client/html/catalog/stock/url/config |
669
|
|
|
*/ |
670
|
|
|
if( !$products->isEmpty() && $this->context()->config()->get( 'client/html/catalog/lists/stock', true ) ) { |
671
|
|
|
return $this->getStockUrl( $this->view(), $products ); |
672
|
|
|
} |
673
|
|
|
|
674
|
|
|
return map(); |
675
|
|
|
} |
676
|
|
|
} |
677
|
|
|
|