| Total Complexity | 44 |
| Total Lines | 738 |
| Duplicated Lines | 0 % |
| Changes | 7 | ||
| 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 | $catIds = $this->categories(); |
||
| 257 | |||
| 258 | if( $catItem = $this->category( $catIds ) ) |
||
| 259 | { |
||
| 260 | $listCatPath = \Aimeos\Controller\Frontend::create( $context, 'catalog' ) |
||
| 261 | ->uses( ['media', 'media/property', 'text'] ) |
||
| 262 | ->getPath( $catItem->getId() ); |
||
| 263 | |||
| 264 | $view->listCatPath = $this->addMetaItems( $listCatPath, $expire, $tags ); |
||
| 265 | $catIds[] = $catItem->getId(); |
||
| 266 | } |
||
| 267 | |||
| 268 | $cntl = \Aimeos\Controller\Frontend::create( $context, 'product' ) |
||
| 269 | ->sort( $sort ) // prioritize user sorting over the sorting through relevance and category |
||
| 270 | ->text( $view->param( 'f_search' ) ) |
||
| 271 | ->price( $view->param( 'f_price' ) ) |
||
| 272 | ->category( $catIds, 'default', $this->level() ) |
||
| 273 | ->radius( $view->param( 'f_point', [] ), $view->param( 'f_dist' ) ) |
||
| 274 | ->supplier( $this->suppliers() ) |
||
| 275 | ->allOf( $this->attributes() ) |
||
| 276 | ->allOf( $view->param( 'f_attrid', [] ) ) |
||
| 277 | ->oneOf( $view->param( 'f_optid', [] ) ) |
||
| 278 | ->oneOf( $view->param( 'f_oneid', [] ) ) |
||
| 279 | ->slice( ( $page - 1 ) * $size, $size ) |
||
| 280 | ->uses( $this->domains() ); |
||
| 281 | |||
| 282 | $this->call( 'conditions', $cntl, $view ); |
||
| 283 | |||
| 284 | $products = $cntl->search( $total ); |
||
| 285 | $articles = $products->getRefItems( 'product', 'default', 'default' )->flat( 1 )->union( $products ); |
||
| 286 | |||
| 287 | $attrMap = $articles->getRefItems( 'attribute' )->flat( 1 )->groupBy( 'attribute.type' ); |
||
| 288 | $attrTypes = $this->attributeTypes( $attrMap->keys() ); |
||
| 289 | |||
| 290 | $this->addMetaItems( $products, $expire, $tags, ['product'] ); |
||
| 291 | |||
| 292 | |||
| 293 | $view->listProductItems = $products; |
||
| 294 | $view->listProductSort = $sort; |
||
| 295 | $view->listProductTotal = $total; |
||
| 296 | |||
| 297 | $view->listPageSize = $size; |
||
| 298 | $view->listPageCurr = $page; |
||
| 299 | $view->listPagePrev = ( $page > 1 ? $page - 1 : 1 ); |
||
| 300 | $view->listPageLast = ( $total != 0 ? min( ceil( $total / $size ), $pages ) : 1 ); |
||
|
|
|||
| 301 | $view->listPageNext = ( $page < $view->listPageLast ? $page + 1 : $view->listPageLast ); |
||
| 302 | |||
| 303 | $view->listAttributeTypes = $attrTypes->col( null, 'attribute.type.code' ); |
||
| 304 | $view->listParams = $this->getClientParams( map( $view->param() )->toArray() ); |
||
| 305 | $view->listStockUrl = $this->stockUrl( $articles ); |
||
| 306 | $view->listPosition = ( $page - 1 ) * $size; |
||
| 307 | |||
| 308 | if( !empty( $type = $view->param( 'l_type' ) ) && ctype_alnum( $type ) ) { |
||
| 309 | return $view->set( 'listPartial', 'catalog/lists/items-' . $type ); |
||
| 310 | } |
||
| 311 | |||
| 312 | return parent::data( $view, $tags, $expire ); |
||
| 313 | } |
||
| 314 | |||
| 315 | |||
| 316 | /** |
||
| 317 | * Modifies the cached content to replace content based on sessions or cookies. |
||
| 318 | * |
||
| 319 | * @param string $content Cached content |
||
| 320 | * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
||
| 321 | * @return string Modified content |
||
| 322 | */ |
||
| 323 | public function modify( string $content, string $uid ) : string |
||
| 326 | } |
||
| 327 | |||
| 328 | |||
| 329 | /** |
||
| 330 | * Returns the attribute IDs used for filtering products |
||
| 331 | * |
||
| 332 | * @return array List of attribute IDs |
||
| 333 | */ |
||
| 334 | protected function attributes() : array |
||
| 359 | } |
||
| 360 | |||
| 361 | |||
| 362 | /** |
||
| 363 | * Returns the attribute type items for the given codes |
||
| 364 | * |
||
| 365 | * @param \Aimeos\Map $codes List of attribute type codes |
||
| 366 | * @return \Aimeos\Map List of attribute type items |
||
| 367 | */ |
||
| 368 | protected function attributeTypes( \Aimeos\Map $codes ) : \Aimeos\Map |
||
| 369 | { |
||
| 370 | $manager = \Aimeos\MShop::create( $this->context(), 'attribute/type' ); |
||
| 371 | |||
| 372 | $filter = $manager->filter( true ) |
||
| 373 | ->add( 'attribute.type.domain', '==', 'product' ) |
||
| 374 | ->add( 'attribute.type.code', '==', $codes ) |
||
| 375 | ->order( 'attribute.type.position' ); |
||
| 376 | |||
| 377 | return $manager->search( $filter->slice( 0, count( $codes ) ) ); |
||
| 378 | } |
||
| 379 | |||
| 380 | |||
| 381 | /** |
||
| 382 | * Returns the category item |
||
| 383 | * |
||
| 384 | * @param array List of category IDs |
||
| 385 | * @return \Aimeos\MShop\Catalog\Item\Iface|null Catalog item |
||
| 386 | */ |
||
| 387 | protected function category( array $catIds ) : ?\Aimeos\MShop\Catalog\Item\Iface |
||
| 401 | } |
||
| 402 | |||
| 403 | |||
| 404 | /** |
||
| 405 | * Returns the category IDs used for filtering products |
||
| 406 | * |
||
| 407 | * @return array List of category IDs |
||
| 408 | */ |
||
| 409 | protected function categories() : array |
||
| 410 | { |
||
| 411 | /** client/html/catalog/lists/catid-default |
||
| 412 | * The default category ID used if none is given as parameter |
||
| 413 | * |
||
| 414 | * If users view a product list page without a category ID in the |
||
| 415 | * parameter list, the first found products are displayed with a |
||
| 416 | * random order. You can circumvent this by configuring a default |
||
| 417 | * category ID that should be used in this case (the ID of the root |
||
| 418 | * category is best for this). In most cases you can set this value |
||
| 419 | * via the administration interface of the shop application. |
||
| 420 | * |
||
| 421 | * @param array|string Category ID or IDs |
||
| 422 | * @since 2014.03 |
||
| 423 | * @see client/html/catalog/lists/sort |
||
| 424 | * @see client/html/catalog/lists/size |
||
| 425 | * @see client/html/catalog/lists/domains |
||
| 426 | * @see client/html/catalog/lists/levels |
||
| 427 | * @see client/html/catalog/lists/attrid-default |
||
| 428 | * @see client/html/catalog/detail/prodid-default |
||
| 429 | * @see client/html/catalog/lists/supid-default |
||
| 430 | * @see client/html/catalog/instock |
||
| 431 | */ |
||
| 432 | $catids = $this->view()->param( 'f_catid', $this->context()->config()->get( 'client/html/catalog/lists/catid-default' ) ); |
||
| 433 | $catids = $catids != null && is_scalar( $catids ) ? explode( ',', (string) $catids ) : $catids; // workaround for TYPO3 |
||
| 434 | |||
| 435 | return array_filter( (array) $catids ); |
||
| 436 | } |
||
| 437 | |||
| 438 | |||
| 439 | /** |
||
| 440 | * Adds additional conditions for filtering |
||
| 441 | * |
||
| 442 | * @param \Aimeos\Controller\Frontend\Product\Iface $cntl Product controller |
||
| 443 | * @param \Aimeos\Base\View\Iface $view View object |
||
| 444 | */ |
||
| 445 | protected function conditions( \Aimeos\Controller\Frontend\Product\Iface $cntl, \Aimeos\Base\View\Iface $view ) |
||
| 471 | } |
||
| 472 | } |
||
| 473 | |||
| 474 | |||
| 475 | /** |
||
| 476 | * Returns the data domains fetched along with the products |
||
| 477 | * |
||
| 478 | * @return array List of domain names |
||
| 479 | */ |
||
| 480 | protected function domains() : array |
||
| 481 | { |
||
| 482 | $config = $this->context()->config(); |
||
| 483 | $domains = ['catalog', 'media', 'media/property', 'price', 'supplier', 'text']; |
||
| 484 | |||
| 485 | /** client/html/catalog/domains |
||
| 486 | * A list of domain names whose items should be available in the catalog view templates |
||
| 487 | * |
||
| 488 | * The templates rendering catalog related data usually add the images and |
||
| 489 | * texts associated to each item. If you want to display additional |
||
| 490 | * content like the 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 can be overwritten by the "client/html/catalog/lists/domains" |
||
| 497 | * configuration option that allows to configure the domain names of the |
||
| 498 | * items fetched specifically for all types of product listings. |
||
| 499 | * |
||
| 500 | * @param array List of domain names |
||
| 501 | * @since 2014.03 |
||
| 502 | * @see client/html/catalog/lists/domains |
||
| 503 | * @see client/html/catalog/lists/size |
||
| 504 | * @see client/html/catalog/lists/levels |
||
| 505 | * @see client/html/catalog/lists/sort |
||
| 506 | * @see client/html/catalog/lists/pages |
||
| 507 | */ |
||
| 508 | $domains = $config->get( 'client/html/catalog/domains', $domains ); |
||
| 509 | |||
| 510 | /** client/html/catalog/lists/domains |
||
| 511 | * A list of domain names whose items should be available in the product list view template |
||
| 512 | * |
||
| 513 | * The templates rendering product lists usually add the images, prices |
||
| 514 | * and texts associated to each product item. If you want to display additional |
||
| 515 | * content like the product attributes, you can configure your own list of |
||
| 516 | * domains (attribute, media, price, product, text, etc. are domains) |
||
| 517 | * whose items are fetched from the storage. Please keep in mind that |
||
| 518 | * the more domains you add to the configuration, the more time is required |
||
| 519 | * for fetching the content! |
||
| 520 | * |
||
| 521 | * This configuration option overwrites the "client/html/catalog/domains" |
||
| 522 | * option that allows to configure the domain names of the items fetched |
||
| 523 | * for all catalog related data. |
||
| 524 | * |
||
| 525 | * @param array List of domain names |
||
| 526 | * @since 2014.03 |
||
| 527 | * @see client/html/catalog/domains |
||
| 528 | * @see client/html/catalog/detail/domains |
||
| 529 | * @see client/html/catalog/stage/domains |
||
| 530 | * @see client/html/catalog/lists/attrid-default |
||
| 531 | * @see client/html/catalog/lists/catid-default |
||
| 532 | * @see client/html/catalog/lists/supid-default |
||
| 533 | * @see client/html/catalog/lists/size |
||
| 534 | * @see client/html/catalog/lists/levels |
||
| 535 | * @see client/html/catalog/lists/sort |
||
| 536 | * @see client/html/catalog/lists/pages |
||
| 537 | * @see client/html/catalog/instock |
||
| 538 | */ |
||
| 539 | $domains = $config->get( 'client/html/catalog/lists/domains', $domains ); |
||
| 540 | |||
| 541 | if( $config->get( 'client/html/catalog/lists/basket-add', false ) ) { |
||
| 542 | $domains = array_merge_recursive( $domains, ['product' => ['default'], 'attribute' => ['variant', 'custom', 'config']] ); |
||
| 543 | } |
||
| 544 | |||
| 545 | return $domains; |
||
| 546 | } |
||
| 547 | |||
| 548 | |||
| 549 | /** |
||
| 550 | * Returns the category depth level |
||
| 551 | * |
||
| 552 | * @return int Category depth level |
||
| 553 | */ |
||
| 554 | protected function level() : int |
||
| 555 | { |
||
| 556 | /** client/html/catalog/lists/levels |
||
| 557 | * Include products of sub-categories in the product list of the current category |
||
| 558 | * |
||
| 559 | * Sometimes it may be useful to show products of sub-categories in the |
||
| 560 | * current category product list, e.g. if the current category contains |
||
| 561 | * no products at all or if there are only a few products in all categories. |
||
| 562 | * |
||
| 563 | * Possible constant values for this setting are: |
||
| 564 | * |
||
| 565 | * * 1 : Only products from the current category |
||
| 566 | * * 2 : Products from the current category and the direct child categories |
||
| 567 | * * 3 : Products from the current category and the whole category sub-tree |
||
| 568 | * |
||
| 569 | * Caution: Please keep in mind that displaying products of sub-categories |
||
| 570 | * can slow down your shop, especially if it contains more than a few |
||
| 571 | * products! You have no real control over the positions of the products |
||
| 572 | * in the result list too because all products from different categories |
||
| 573 | * with the same position value are placed randomly. |
||
| 574 | * |
||
| 575 | * Usually, a better way is to associate products to all categories they |
||
| 576 | * should be listed in. This can be done manually if there are only a few |
||
| 577 | * ones or during the product import automatically. |
||
| 578 | * |
||
| 579 | * @param integer Tree level constant |
||
| 580 | * @since 2015.11 |
||
| 581 | * @see client/html/catalog/lists/attrid-default |
||
| 582 | * @see client/html/catalog/lists/catid-default |
||
| 583 | * @see client/html/catalog/lists/supid-default |
||
| 584 | * @see client/html/catalog/lists/domains |
||
| 585 | * @see client/html/catalog/lists/size |
||
| 586 | * @see client/html/catalog/lists/sort |
||
| 587 | * @see client/html/catalog/lists/pages |
||
| 588 | * @see client/html/catalog/instock |
||
| 589 | */ |
||
| 590 | return $this->context()->config()->get( 'client/html/catalog/lists/levels', \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ); |
||
| 591 | } |
||
| 592 | |||
| 593 | |||
| 594 | /** |
||
| 595 | * Returns the number of allowed pages |
||
| 596 | * |
||
| 597 | * @return int Number of allowed pages |
||
| 598 | */ |
||
| 599 | protected function pages() : int |
||
| 623 | } |
||
| 624 | |||
| 625 | |||
| 626 | /** |
||
| 627 | * Returns the maximum products per page |
||
| 628 | * |
||
| 629 | * @return int Maximum products per page |
||
| 630 | */ |
||
| 631 | protected function size() : int |
||
| 632 | { |
||
| 633 | /** client/html/catalog/lists/size |
||
| 634 | * The number of products shown in a list page |
||
| 635 | * |
||
| 636 | * Limits the number of products that are shown in the list pages to the |
||
| 637 | * given value. If more products are available, the products are split |
||
| 638 | * into bunches which will be shown on their own list page. The user is |
||
| 639 | * able to move to the next page (or previous one if it's not the first) |
||
| 640 | * to display the next (or previous) products. |
||
| 641 | * |
||
| 642 | * The value must be an integer number from 1 to 100. Negative values as |
||
| 643 | * well as values above 100 are not allowed. The value can be overwritten |
||
| 644 | * per request if the "l_size" parameter is part of the URL. |
||
| 645 | * |
||
| 646 | * @param integer Number of products |
||
| 647 | * @since 2014.03 |
||
| 648 | * @see client/html/catalog/lists/attrid-default |
||
| 649 | * @see client/html/catalog/lists/catid-default |
||
| 650 | * @see client/html/catalog/lists/supid-default |
||
| 651 | * @see client/html/catalog/lists/domains |
||
| 652 | * @see client/html/catalog/lists/levels |
||
| 653 | * @see client/html/catalog/lists/sort |
||
| 654 | * @see client/html/catalog/lists/pages |
||
| 655 | * @see client/html/catalog/instock |
||
| 656 | */ |
||
| 657 | $size = $this->context()->config()->get( 'client/html/catalog/lists/size', 48 ); |
||
| 658 | |||
| 659 | return min( max( $this->view()->param( 'l_size', $size ), 1 ), 100 ); |
||
| 660 | } |
||
| 661 | |||
| 662 | |||
| 663 | /** |
||
| 664 | * Returns the product sorting |
||
| 665 | * |
||
| 666 | * @return string Product sorting |
||
| 667 | */ |
||
| 668 | protected function sort() : string |
||
| 669 | { |
||
| 670 | /** client/html/catalog/lists/sort |
||
| 671 | * Default sorting of product list if no other sorting is given by parameter |
||
| 672 | * |
||
| 673 | * Configures the standard sorting of products in list views. This sorting is used |
||
| 674 | * as long as it's not overwritten by an URL parameter. Except "relevance", all |
||
| 675 | * other sort codes can be prefixed by a "-" (minus) sign to sort the products in |
||
| 676 | * a descending order. By default, the sorting is ascending. |
||
| 677 | * |
||
| 678 | * @param string Sort code "relevance", "name", "-name", "price", "-price", "ctime" or "-ctime" |
||
| 679 | * @since 2018.07 |
||
| 680 | * @see client/html/catalog/lists/attrid-default |
||
| 681 | * @see client/html/catalog/lists/catid-default |
||
| 682 | * @see client/html/catalog/lists/supid-default |
||
| 683 | * @see client/html/catalog/lists/domains |
||
| 684 | * @see client/html/catalog/lists/levels |
||
| 685 | * @see client/html/catalog/lists/size |
||
| 686 | * @see client/html/catalog/instock |
||
| 687 | */ |
||
| 688 | return $this->view()->param( 'f_sort', $this->context()->config()->get( 'client/html/catalog/lists/sort', 'relevance' ) ); |
||
| 689 | } |
||
| 690 | |||
| 691 | |||
| 692 | /** |
||
| 693 | * Returns the supplier IDs used for filtering products |
||
| 694 | * |
||
| 695 | * @return array List of supplier IDs |
||
| 696 | */ |
||
| 697 | protected function suppliers() : array |
||
| 698 | { |
||
| 699 | /** client/html/catalog/lists/supid-default |
||
| 700 | * The default supplier ID used if none is given as parameter |
||
| 701 | * |
||
| 702 | * Products in the list page can be limited to one or more suppliers. |
||
| 703 | * By default, the products are not limited to any supplier until one or |
||
| 704 | * more supplier IDs are passed in the URL using the f_supid parameter. |
||
| 705 | * You can also configure the default supplier IDs for limiting the |
||
| 706 | * products if no IDs are passed in the URL using this configuration. |
||
| 707 | * |
||
| 708 | * @param array|string Supplier ID or IDs |
||
| 709 | * @since 2021.01 |
||
| 710 | * @see client/html/catalog/lists/sort |
||
| 711 | * @see client/html/catalog/lists/size |
||
| 712 | * @see client/html/catalog/lists/domains |
||
| 713 | * @see client/html/catalog/lists/levels |
||
| 714 | * @see client/html/catalog/lists/attrid-default |
||
| 715 | * @see client/html/catalog/lists/catid-default |
||
| 716 | * @see client/html/catalog/detail/prodid-default |
||
| 717 | * @see client/html/catalog/instock |
||
| 718 | */ |
||
| 719 | $supids = $this->view()->param( 'f_supid', $this->context()->config()->get( 'client/html/catalog/lists/supid-default' ) ); |
||
| 720 | $supids = $supids != null && is_scalar( $supids ) ? explode( ',', $supids ) : $supids; // workaround for TYPO3 |
||
| 721 | |||
| 722 | return (array) $supids; |
||
| 723 | } |
||
| 724 | |||
| 725 | |||
| 726 | /** |
||
| 727 | * Returns the URLs for fetching stock information |
||
| 728 | * |
||
| 729 | * @param \Aimeos\Map $products Products to fetch stock information for |
||
| 730 | * @return \Aimeos\Map List of stock URLs |
||
| 731 | */ |
||
| 732 | protected function stockUrl( \Aimeos\Map $products ) : \Aimeos\Map |
||
| 758 | } |
||
| 759 | |||
| 760 | |||
| 761 | /** client/html/catalog/lists/decorators/excludes |
||
| 762 | * Excludes decorators added by the "common" option from the catalog lists html client |
||
| 763 | * |
||
| 764 | * Decorators extend the functionality of a class by adding new aspects |
||
| 765 | * (e.g. log what is currently done), executing the methods of the underlying |
||
| 766 | * class only in certain conditions (e.g. only for logged in users) or |
||
| 829 |