Total Complexity | 41 |
Total Lines | 713 |
Duplicated Lines | 0 % |
Changes | 6 | ||
Bugs | 0 | Features | 0 |
Complex classes like Standard often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Standard, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
20 | class Standard |
||
21 | extends \Aimeos\Client\Html\Catalog\Base |
||
22 | implements \Aimeos\Client\Html\Common\Client\Factory\Iface |
||
23 | { |
||
24 | /** client/html/catalog/lists/name |
||
25 | * Class name of the used catalog list client implementation |
||
26 | * |
||
27 | * Each default HTML client 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 client factory knows which class it |
||
30 | * has to instantiate. |
||
31 | * |
||
32 | * For example, if the name of the default class is |
||
33 | * |
||
34 | * \Aimeos\Client\Html\Catalog\Lists\Standard |
||
35 | * |
||
36 | * and you want to replace it with your own version named |
||
37 | * |
||
38 | * \Aimeos\Client\Html\Catalog\Lists\Mylist |
||
39 | * |
||
40 | * then you have to set the this configuration option: |
||
41 | * |
||
42 | * client/html/catalog/lists/name = Mylist |
||
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 "MyList"! |
||
52 | * |
||
53 | * @param string Last part of the class name |
||
54 | * @since 2014.03 |
||
55 | */ |
||
56 | |||
57 | |||
58 | private array $tags = []; |
||
59 | private ?string $expire = null; |
||
60 | private ?\Aimeos\Base\View\Iface $view = null; |
||
61 | |||
62 | |||
63 | /** |
||
64 | * Returns the HTML code for insertion into the body. |
||
65 | * |
||
66 | * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
||
67 | * @return string HTML code |
||
68 | */ |
||
69 | public function body( string $uid = '' ) : string |
||
70 | { |
||
71 | $view = $this->view(); |
||
72 | $prefixes = ['f_catid', 'f_supid', 'f_sort', 'l_page', 'l_type']; |
||
73 | |||
74 | /** client/html/catalog/lists/cache |
||
75 | * Enables or disables caching only for the catalog lists component |
||
76 | * |
||
77 | * Disable caching for components can be useful if you would have too much |
||
78 | * entries to cache or if the component contains non-cacheable parts that |
||
79 | * can't be replaced using the modify() method. |
||
80 | * |
||
81 | * @param boolean True to enable caching, false to disable |
||
82 | * @see client/html/catalog/detail/cache |
||
83 | * @see client/html/catalog/filter/cache |
||
84 | * @see client/html/catalog/stage/cache |
||
85 | */ |
||
86 | |||
87 | /** client/html/catalog/lists |
||
88 | * All parameters defined for the catalog list component and its subparts |
||
89 | * |
||
90 | * This returns all settings related to the filter component. |
||
91 | * Please refer to the single settings for details. |
||
92 | * |
||
93 | * @param array Associative list of name/value settings |
||
94 | * @see client/html/catalog#list |
||
95 | */ |
||
96 | $confkey = 'client/html/catalog/lists'; |
||
97 | |||
98 | $args = map( $view->param() )->except( ['f_catid', 'f_name', 'f_supid', 's_name'] )->filter( function( $val, $key ) { |
||
99 | return !strncmp( $key, 'f_', 2 ) || !strncmp( $key, 'l_', 2 ); |
||
100 | } ); |
||
101 | |||
102 | if( $args->isEmpty() && ( $html = $this->cached( 'body', $uid, $prefixes, $confkey ) ) !== null ) { |
||
103 | return $this->modify( $html, $uid ); |
||
104 | } |
||
105 | |||
106 | /** client/html/catalog/lists/template-body |
||
107 | * Relative path to the HTML body template of the catalog list client. |
||
108 | * |
||
109 | * The template file contains the HTML code and processing instructions |
||
110 | * to generate the result shown in the body of the frontend. The |
||
111 | * configuration string is the path to the template file relative |
||
112 | * to the templates directory (usually in templates/client/html). |
||
113 | * |
||
114 | * You can overwrite the template file configuration in extensions and |
||
115 | * provide alternative templates. These alternative templates should be |
||
116 | * named like the default one but suffixed by |
||
117 | * an unique name. You may use the name of your project for this. If |
||
118 | * you've implemented an alternative client class as well, it |
||
119 | * should be suffixed by the name of the new class. |
||
120 | * |
||
121 | * It's also possible to create a specific template for each type, e.g. |
||
122 | * for the grid, list or whatever view you want to offer your users. In |
||
123 | * that case, you can configure the template by adding "-<type>" to the |
||
124 | * configuration key. To configure an alternative list view template for |
||
125 | * example, use the key |
||
126 | * |
||
127 | * client/html/catalog/lists/template-body-list = catalog/lists/body-list.php |
||
128 | * |
||
129 | * The argument is the relative path to the new template file. The type of |
||
130 | * the view is determined by the "l_type" parameter (allowed characters for |
||
131 | * the types are a-z and 0-9). The catalog list type subpart |
||
132 | * contains the template for switching between list types. |
||
133 | * |
||
134 | * @param string Relative path to the template creating code for the HTML page body |
||
135 | * @since 2014.03 |
||
136 | * @see client/html/catalog/lists/template-header |
||
137 | * @see client/html/catalog/lists/type/template-body |
||
138 | */ |
||
139 | $template = $this->context()->config()->get( 'client/html/catalog/lists/template-body', 'catalog/lists/body' ); |
||
140 | |||
141 | $view = $this->view = $this->view ?? $this->object()->data( $view, $this->tags, $this->expire ); |
||
142 | $html = $this->modify( $view->render( $template ), $uid ); |
||
143 | |||
144 | if( $args->isEmpty() ) { |
||
145 | return $this->cache( 'body', $uid, $prefixes, $confkey, $html, $this->tags, $this->expire ); |
||
146 | } |
||
147 | |||
148 | return $html; |
||
149 | } |
||
150 | |||
151 | |||
152 | /** |
||
153 | * Returns the HTML string for insertion into the header. |
||
154 | * |
||
155 | * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
||
156 | * @return string|null String including HTML tags for the header on error |
||
157 | */ |
||
158 | public function header( string $uid = '' ) : ?string |
||
216 | } |
||
217 | |||
218 | |||
219 | /** |
||
220 | * Processes the input, e.g. store given values. |
||
221 | * |
||
222 | * A view must be available and this method doesn't generate any output |
||
223 | * besides setting view variables if necessary. |
||
224 | */ |
||
225 | public function init() |
||
226 | { |
||
227 | $view = $this->view(); |
||
228 | $context = $this->context(); |
||
229 | $session = $context->session(); |
||
230 | |||
231 | $params = $view->param(); |
||
232 | $site = $context->locale()->getSiteItem()->getCode(); |
||
233 | $key = $view->param( 'f_catid' ) ? 'client/html/catalog/tree/url' : 'client/html/catalog/lists/url'; |
||
234 | |||
235 | $session->set( 'aimeos/catalog/last/' . $site, $view->link( $key, $params ) ); |
||
236 | $session->set( 'aimeos/catalog/lists/params/last/' . $site, $params ); |
||
237 | } |
||
238 | |||
239 | |||
240 | /** |
||
241 | * Sets the necessary parameter values in the view. |
||
242 | * |
||
243 | * @param \Aimeos\Base\View\Iface $view The view object which generates the HTML output |
||
244 | * @param array &$tags Result array for the list of tags that are associated to the output |
||
245 | * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
||
246 | * @return \Aimeos\Base\View\Iface Modified view object |
||
247 | */ |
||
248 | public function data( \Aimeos\Base\View\Iface $view, array &$tags = [], ?string &$expire = null ) : \Aimeos\Base\View\Iface |
||
249 | { |
||
250 | $total = 0; |
||
251 | $sort = $this->sort(); |
||
252 | $size = $this->size(); |
||
253 | $pages = $this->pages(); |
||
254 | $context = $this->context(); |
||
255 | $page = min( max( $view->param( 'l_page', 1 ), 1 ), $pages ); |
||
256 | |||
257 | if( !empty( $catIds = $this->categories() ) ) |
||
258 | { |
||
259 | $listCatPath = \Aimeos\Controller\Frontend::create( $context, 'catalog' ) |
||
260 | ->uses( ['media', 'media/property', 'text'] ) |
||
261 | ->getPath( current( $catIds ) ); |
||
262 | |||
263 | $view->listCatPath = $this->addMetaItems( $listCatPath, $expire, $tags ); |
||
264 | } |
||
265 | |||
266 | $cntl = \Aimeos\Controller\Frontend::create( $context, 'product' ) |
||
267 | ->sort( $sort ) // prioritize user sorting over the sorting through relevance and category |
||
268 | ->text( $view->param( 'f_search' ) ) |
||
269 | ->price( $view->param( 'f_price' ) ) |
||
270 | ->category( $catIds, 'default', $this->level() ) |
||
271 | ->radius( $view->param( 'f_point', [] ), $view->param( 'f_dist' ) ) |
||
272 | ->supplier( $this->suppliers() ) |
||
273 | ->allOf( $this->attributes() ) |
||
274 | ->allOf( $view->param( 'f_attrid', [] ) ) |
||
275 | ->oneOf( $view->param( 'f_optid', [] ) ) |
||
276 | ->oneOf( $view->param( 'f_oneid', [] ) ) |
||
277 | ->slice( ( $page - 1 ) * $size, $size ) |
||
278 | ->uses( $this->domains() ); |
||
279 | |||
280 | $this->call( 'conditions', $cntl, $view ); |
||
281 | |||
282 | $products = $cntl->search( $total ); |
||
283 | $articles = $products->getRefItems( 'product', 'default', 'default' )->flat( 1 )->union( $products ); |
||
284 | |||
285 | $attrMap = $articles->getRefItems( 'attribute' )->flat( 1 )->groupBy( 'attribute.type' ); |
||
286 | $attrTypes = $this->attributeTypes( $attrMap->keys() ); |
||
287 | |||
288 | $this->addMetaItems( $products, $expire, $tags, ['product'] ); |
||
289 | |||
290 | |||
291 | $view->listProductItems = $products; |
||
292 | $view->listProductSort = $sort; |
||
293 | $view->listProductTotal = $total; |
||
294 | |||
295 | $view->listPageSize = $size; |
||
296 | $view->listPageCurr = $page; |
||
297 | $view->listPagePrev = ( $page > 1 ? $page - 1 : 1 ); |
||
298 | $view->listPageLast = ( $total != 0 ? min( ceil( $total / $size ), $pages ) : 1 ); |
||
|
|||
299 | $view->listPageNext = ( $page < $view->listPageLast ? $page + 1 : $view->listPageLast ); |
||
300 | |||
301 | $view->listAttributeTypes = $attrTypes->col( null, 'attribute.type.code' ); |
||
302 | $view->listParams = $this->getClientParams( map( $view->param() )->toArray() ); |
||
303 | $view->listStockUrl = $this->stockUrl( $articles ); |
||
304 | $view->listPosition = ( $page - 1 ) * $size; |
||
305 | |||
306 | if( !empty( $type = $view->param( 'l_type' ) ) && ctype_alnum( $type ) ) { |
||
307 | return $view->set( 'listPartial', 'catalog/lists/items-' . $type ); |
||
308 | } |
||
309 | |||
310 | return parent::data( $view, $tags, $expire ); |
||
311 | } |
||
312 | |||
313 | |||
314 | /** |
||
315 | * Modifies the cached content to replace content based on sessions or cookies. |
||
316 | * |
||
317 | * @param string $content Cached content |
||
318 | * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
||
319 | * @return string Modified content |
||
320 | */ |
||
321 | public function modify( string $content, string $uid ) : string |
||
324 | } |
||
325 | |||
326 | |||
327 | /** |
||
328 | * Returns the attribute IDs used for filtering products |
||
329 | * |
||
330 | * @return array List of attribute IDs |
||
331 | */ |
||
332 | protected function attributes() : array |
||
333 | { |
||
334 | /** client/html/catalog/lists/attrid-default |
||
335 | * Additional attribute IDs used to limit search results |
||
336 | * |
||
337 | * Using this setting, products result lists can be limited by additional |
||
338 | * attributes. Then, only products which have associated the configured |
||
339 | * attribute IDs will be returned and shown in the frontend. The value |
||
340 | * can be either a single attribute ID or a list of attribute IDs. |
||
341 | * |
||
342 | * @param array|string Attribute ID or IDs |
||
343 | * @since 2021.10 |
||
344 | * @see client/html/catalog/lists/sort |
||
345 | * @see client/html/catalog/lists/size |
||
346 | * @see client/html/catalog/lists/domains |
||
347 | * @see client/html/catalog/lists/levels |
||
348 | * @see client/html/catalog/lists/catid-default |
||
349 | * @see client/html/catalog/lists/supid-default |
||
350 | * @see client/html/catalog/detail/prodid-default |
||
351 | * @see client/html/catalog/instock |
||
352 | */ |
||
353 | $attrids = $this->context()->config()->get( 'client/html/catalog/lists/attrid-default' ); |
||
354 | $attrids = $attrids != null && is_scalar( $attrids ) ? explode( ',', $attrids ) : $attrids; // workaround for TYPO3 |
||
355 | |||
356 | return (array) $attrids; |
||
357 | } |
||
358 | |||
359 | |||
360 | /** |
||
361 | * Returns the attribute type items for the given codes |
||
362 | * |
||
363 | * @param \Aimeos\Map $codes List of attribute type codes |
||
364 | * @return \Aimeos\Map List of attribute type items |
||
365 | */ |
||
366 | protected function attributeTypes( \Aimeos\Map $codes ) : \Aimeos\Map |
||
367 | { |
||
368 | $manager = \Aimeos\MShop::create( $this->context(), 'attribute/type' ); |
||
369 | |||
370 | $filter = $manager->filter( true ) |
||
371 | ->add( 'attribute.type.domain', '==', 'product' ) |
||
372 | ->add( 'attribute.type.code', '==', $codes ) |
||
373 | ->order( 'attribute.type.position' ); |
||
374 | |||
375 | return $manager->search( $filter->slice( 0, count( $codes ) ) ); |
||
376 | } |
||
377 | |||
378 | |||
379 | /** |
||
380 | * Returns the category IDs used for filtering products |
||
381 | * |
||
382 | * @return array List of category IDs |
||
383 | */ |
||
384 | protected function categories() : array |
||
385 | { |
||
386 | /** client/html/catalog/lists/catid-default |
||
387 | * The default category ID used if none is given as parameter |
||
388 | * |
||
389 | * If users view a product list page without a category ID in the |
||
390 | * parameter list, the first found products are displayed with a |
||
391 | * random order. You can circumvent this by configuring a default |
||
392 | * category ID that should be used in this case (the ID of the root |
||
393 | * category is best for this). In most cases you can set this value |
||
394 | * via the administration interface of the shop application. |
||
395 | * |
||
396 | * @param array|string Category ID or IDs |
||
397 | * @since 2014.03 |
||
398 | * @see client/html/catalog/lists/sort |
||
399 | * @see client/html/catalog/lists/size |
||
400 | * @see client/html/catalog/lists/domains |
||
401 | * @see client/html/catalog/lists/levels |
||
402 | * @see client/html/catalog/lists/attrid-default |
||
403 | * @see client/html/catalog/detail/prodid-default |
||
404 | * @see client/html/catalog/lists/supid-default |
||
405 | * @see client/html/catalog/instock |
||
406 | */ |
||
407 | $catids = $this->view()->param( 'f_catid', $this->context()->config()->get( 'client/html/catalog/lists/catid-default' ) ); |
||
408 | $catids = $catids != null && is_scalar( $catids ) ? explode( ',', $catids ) : $catids; // workaround for TYPO3 |
||
409 | |||
410 | return array_filter( (array) $catids ); |
||
411 | } |
||
412 | |||
413 | |||
414 | /** |
||
415 | * Adds additional conditions for filtering |
||
416 | * |
||
417 | * @param \Aimeos\Controller\Frontend\Product\Iface $cntl Product controller |
||
418 | * @param \Aimeos\Base\View\Iface $view View object |
||
419 | */ |
||
420 | protected function conditions( \Aimeos\Controller\Frontend\Product\Iface $cntl, \Aimeos\Base\View\Iface $view ) |
||
446 | } |
||
447 | } |
||
448 | |||
449 | |||
450 | /** |
||
451 | * Returns the data domains fetched along with the products |
||
452 | * |
||
453 | * @return array List of domain names |
||
454 | */ |
||
455 | protected function domains() : array |
||
456 | { |
||
457 | $config = $this->context()->config(); |
||
458 | $domains = ['catalog', 'media', 'media/property', 'price', 'supplier', 'text']; |
||
459 | |||
460 | /** client/html/catalog/domains |
||
461 | * A list of domain names whose items should be available in the catalog view templates |
||
462 | * |
||
463 | * The templates rendering catalog related data usually add the images and |
||
464 | * texts associated to each item. If you want to display additional |
||
465 | * content like the attributes, you can configure your own list of |
||
466 | * domains (attribute, media, price, product, text, etc. are domains) |
||
467 | * whose items are fetched from the storage. Please keep in mind that |
||
468 | * the more domains you add to the configuration, the more time is required |
||
469 | * for fetching the content! |
||
470 | * |
||
471 | * This configuration option can be overwritten by the "client/html/catalog/lists/domains" |
||
472 | * configuration option that allows to configure the domain names of the |
||
473 | * items fetched specifically for all types of product listings. |
||
474 | * |
||
475 | * @param array List of domain names |
||
476 | * @since 2014.03 |
||
477 | * @see client/html/catalog/lists/domains |
||
478 | * @see client/html/catalog/lists/size |
||
479 | * @see client/html/catalog/lists/levels |
||
480 | * @see client/html/catalog/lists/sort |
||
481 | * @see client/html/catalog/lists/pages |
||
482 | */ |
||
483 | $domains = $config->get( 'client/html/catalog/domains', $domains ); |
||
484 | |||
485 | /** client/html/catalog/lists/domains |
||
486 | * A list of domain names whose items should be available in the product list view template |
||
487 | * |
||
488 | * The templates rendering product lists usually add the images, prices |
||
489 | * and texts associated to each product item. If you want to display additional |
||
490 | * content like the product attributes, you can configure your own list of |
||
491 | * domains (attribute, media, price, product, text, etc. are domains) |
||
492 | * whose items are fetched from the storage. Please keep in mind that |
||
493 | * the more domains you add to the configuration, the more time is required |
||
494 | * for fetching the content! |
||
495 | * |
||
496 | * This configuration option overwrites the "client/html/catalog/domains" |
||
497 | * option that allows to configure the domain names of the items fetched |
||
498 | * for all catalog related data. |
||
499 | * |
||
500 | * @param array List of domain names |
||
501 | * @since 2014.03 |
||
502 | * @see client/html/catalog/domains |
||
503 | * @see client/html/catalog/detail/domains |
||
504 | * @see client/html/catalog/stage/domains |
||
505 | * @see client/html/catalog/lists/attrid-default |
||
506 | * @see client/html/catalog/lists/catid-default |
||
507 | * @see client/html/catalog/lists/supid-default |
||
508 | * @see client/html/catalog/lists/size |
||
509 | * @see client/html/catalog/lists/levels |
||
510 | * @see client/html/catalog/lists/sort |
||
511 | * @see client/html/catalog/lists/pages |
||
512 | * @see client/html/catalog/instock |
||
513 | */ |
||
514 | $domains = $config->get( 'client/html/catalog/lists/domains', $domains ); |
||
515 | |||
516 | if( $config->get( 'client/html/catalog/lists/basket-add', false ) ) { |
||
517 | $domains = array_merge_recursive( $domains, ['product' => ['default'], 'attribute' => ['variant', 'custom', 'config']] ); |
||
518 | } |
||
519 | |||
520 | return $domains; |
||
521 | } |
||
522 | |||
523 | |||
524 | /** |
||
525 | * Returns the category depth level |
||
526 | * |
||
527 | * @return int Category depth level |
||
528 | */ |
||
529 | protected function level() : int |
||
530 | { |
||
531 | /** client/html/catalog/lists/levels |
||
532 | * Include products of sub-categories in the product list of the current category |
||
533 | * |
||
534 | * Sometimes it may be useful to show products of sub-categories in the |
||
535 | * current category product list, e.g. if the current category contains |
||
536 | * no products at all or if there are only a few products in all categories. |
||
537 | * |
||
538 | * Possible constant values for this setting are: |
||
539 | * |
||
540 | * * 1 : Only products from the current category |
||
541 | * * 2 : Products from the current category and the direct child categories |
||
542 | * * 3 : Products from the current category and the whole category sub-tree |
||
543 | * |
||
544 | * Caution: Please keep in mind that displaying products of sub-categories |
||
545 | * can slow down your shop, especially if it contains more than a few |
||
546 | * products! You have no real control over the positions of the products |
||
547 | * in the result list too because all products from different categories |
||
548 | * with the same position value are placed randomly. |
||
549 | * |
||
550 | * Usually, a better way is to associate products to all categories they |
||
551 | * should be listed in. This can be done manually if there are only a few |
||
552 | * ones or during the product import automatically. |
||
553 | * |
||
554 | * @param integer Tree level constant |
||
555 | * @since 2015.11 |
||
556 | * @see client/html/catalog/lists/attrid-default |
||
557 | * @see client/html/catalog/lists/catid-default |
||
558 | * @see client/html/catalog/lists/supid-default |
||
559 | * @see client/html/catalog/lists/domains |
||
560 | * @see client/html/catalog/lists/size |
||
561 | * @see client/html/catalog/lists/sort |
||
562 | * @see client/html/catalog/lists/pages |
||
563 | * @see client/html/catalog/instock |
||
564 | */ |
||
565 | return $this->context()->config()->get( 'client/html/catalog/lists/levels', \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ); |
||
566 | } |
||
567 | |||
568 | |||
569 | /** |
||
570 | * Returns the number of allowed pages |
||
571 | * |
||
572 | * @return int Number of allowed pages |
||
573 | */ |
||
574 | protected function pages() : int |
||
598 | } |
||
599 | |||
600 | |||
601 | /** |
||
602 | * Returns the maximum products per page |
||
603 | * |
||
604 | * @return int Maximum products per page |
||
605 | */ |
||
606 | protected function size() : int |
||
607 | { |
||
608 | /** client/html/catalog/lists/size |
||
609 | * The number of products shown in a list page |
||
610 | * |
||
611 | * Limits the number of products that are shown in the list pages to the |
||
612 | * given value. If more products are available, the products are split |
||
613 | * into bunches which will be shown on their own list page. The user is |
||
614 | * able to move to the next page (or previous one if it's not the first) |
||
615 | * to display the next (or previous) products. |
||
616 | * |
||
617 | * The value must be an integer number from 1 to 100. Negative values as |
||
618 | * well as values above 100 are not allowed. The value can be overwritten |
||
619 | * per request if the "l_size" parameter is part of the URL. |
||
620 | * |
||
621 | * @param integer Number of products |
||
622 | * @since 2014.03 |
||
623 | * @see client/html/catalog/lists/attrid-default |
||
624 | * @see client/html/catalog/lists/catid-default |
||
625 | * @see client/html/catalog/lists/supid-default |
||
626 | * @see client/html/catalog/lists/domains |
||
627 | * @see client/html/catalog/lists/levels |
||
628 | * @see client/html/catalog/lists/sort |
||
629 | * @see client/html/catalog/lists/pages |
||
630 | * @see client/html/catalog/instock |
||
631 | */ |
||
632 | $size = $this->context()->config()->get( 'client/html/catalog/lists/size', 48 ); |
||
633 | |||
634 | return min( max( $this->view()->param( 'l_size', $size ), 1 ), 100 ); |
||
635 | } |
||
636 | |||
637 | |||
638 | /** |
||
639 | * Returns the product sorting |
||
640 | * |
||
641 | * @return string Product sorting |
||
642 | */ |
||
643 | protected function sort() : string |
||
644 | { |
||
645 | /** client/html/catalog/lists/sort |
||
646 | * Default sorting of product list if no other sorting is given by parameter |
||
647 | * |
||
648 | * Configures the standard sorting of products in list views. This sorting is used |
||
649 | * as long as it's not overwritten by an URL parameter. Except "relevance", all |
||
650 | * other sort codes can be prefixed by a "-" (minus) sign to sort the products in |
||
651 | * a descending order. By default, the sorting is ascending. |
||
652 | * |
||
653 | * @param string Sort code "relevance", "name", "-name", "price", "-price", "ctime" or "-ctime" |
||
654 | * @since 2018.07 |
||
655 | * @see client/html/catalog/lists/attrid-default |
||
656 | * @see client/html/catalog/lists/catid-default |
||
657 | * @see client/html/catalog/lists/supid-default |
||
658 | * @see client/html/catalog/lists/domains |
||
659 | * @see client/html/catalog/lists/levels |
||
660 | * @see client/html/catalog/lists/size |
||
661 | * @see client/html/catalog/instock |
||
662 | */ |
||
663 | return $this->view()->param( 'f_sort', $this->context()->config()->get( 'client/html/catalog/lists/sort', 'relevance' ) ); |
||
664 | } |
||
665 | |||
666 | |||
667 | /** |
||
668 | * Returns the supplier IDs used for filtering products |
||
669 | * |
||
670 | * @return array List of supplier IDs |
||
671 | */ |
||
672 | protected function suppliers() : array |
||
673 | { |
||
674 | /** client/html/catalog/lists/supid-default |
||
675 | * The default supplier ID used if none is given as parameter |
||
676 | * |
||
677 | * Products in the list page can be limited to one or more suppliers. |
||
678 | * By default, the products are not limited to any supplier until one or |
||
679 | * more supplier IDs are passed in the URL using the f_supid parameter. |
||
680 | * You can also configure the default supplier IDs for limiting the |
||
681 | * products if no IDs are passed in the URL using this configuration. |
||
682 | * |
||
683 | * @param array|string Supplier ID or IDs |
||
684 | * @since 2021.01 |
||
685 | * @see client/html/catalog/lists/sort |
||
686 | * @see client/html/catalog/lists/size |
||
687 | * @see client/html/catalog/lists/domains |
||
688 | * @see client/html/catalog/lists/levels |
||
689 | * @see client/html/catalog/lists/attrid-default |
||
690 | * @see client/html/catalog/lists/catid-default |
||
691 | * @see client/html/catalog/detail/prodid-default |
||
692 | * @see client/html/catalog/instock |
||
693 | */ |
||
694 | $supids = $this->view()->param( 'f_supid', $this->context()->config()->get( 'client/html/catalog/lists/supid-default' ) ); |
||
695 | $supids = $supids != null && is_scalar( $supids ) ? explode( ',', $supids ) : $supids; // workaround for TYPO3 |
||
696 | |||
697 | return (array) $supids; |
||
698 | } |
||
699 | |||
700 | |||
701 | /** |
||
702 | * Returns the URLs for fetching stock information |
||
703 | * |
||
704 | * @param \Aimeos\Map $products Products to fetch stock information for |
||
705 | * @return \Aimeos\Map List of stock URLs |
||
706 | */ |
||
707 | protected function stockUrl( \Aimeos\Map $products ) : \Aimeos\Map |
||
733 | } |
||
734 | |||
735 | |||
736 | /** client/html/catalog/lists/decorators/excludes |
||
737 | * Excludes decorators added by the "common" option from the catalog lists html client |
||
738 | * |
||
739 | * Decorators extend the functionality of a class by adding new aspects |
||
740 | * (e.g. log what is currently done), executing the methods of the underlying |
||
741 | * class only in certain conditions (e.g. only for logged in users) or |
||
742 | * modify what is returned to the caller. |
||
743 | * |
||
804 |