Conditions | 6 |
Paths | 19 |
Total Lines | 61 |
Code Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
79 | * in the basket. This works for all type of products, even for selection products |
||
80 | * with product variants and product bundles. By default, also optional attributes |
||
81 | * are displayed if they have been associated to a product. |
||
82 | * |
||
83 | * @param boolean True to display the button, false to hide it |
||
84 | * @since 2020.10 |
||
85 | * @see client/html/catalog/home/basket-add |
||
86 | * @see client/html/catalog/lists/basket-add |
||
87 | * @see client/html/catalog/detail/basket-add |
||
88 | * @see client/html/catalog/product/basket-add |
||
89 | */ |
||
90 | if( $view->config( 'client/html/basket/related/basket-add', false ) ) { |
||
91 | $domains = array_merge_recursive( $domains, ['product' => ['default'], 'attribute' => ['variant', 'custom', 'config']] ); |
||
92 | } |
||
93 | |||
94 | $prodIds = $basket->getProducts() |
||
95 | ->concat( $basket->getProducts()->getProducts() ) |
||
96 | ->col( 'order.base.product.parentproductid' ) |
||
97 | ->unique()->all(); |
||
98 | |||
99 | $view->boughtItems = $cntl->uses( $domains )->product( $prodIds )->search() |
||
100 | ->getListItems( 'product', 'bought-together' ) |
||
101 | ->flat( 1 ) |
||
102 | ->usort( function( $a, $b ) { |
||
103 | return $a->getPosition() <=> $b->getPosition(); |
||
104 | } ) |
||
105 | ->getRefItem() |
||
106 | ->filter() |
||
107 | ->slice( 0, $size ) |
||
108 | ->col( null, 'product.id' ); |
||
109 | |||
110 | return parent::data( $view, $tags, $expire ); |
||
111 | } |
||
112 | |||
113 | |||
114 | /** client/html/basket/related/template-body |
||
115 | * Relative path to the HTML body template of the basket related client. |
||
116 | * |
||
117 | * The template file contains the HTML code and processing instructions |
||
118 | * to generate the result shown in the body of the frontend. The |
||
119 | * configuration string is the path to the template file relative |
||
120 | * to the templates directory (usually in client/html/templates). |
||
121 | * |
||
122 | * You can overwrite the template file configuration in extensions and |
||
123 | * provide alternative templates. These alternative templates should be |
||
124 | * named like the default one but suffixed by |
||
125 | * an unique name. You may use the name of your project for this. If |
||
126 | * you've implemented an alternative client class as well, it |
||
127 | * should be suffixed by the name of the new class. |
||
128 | * |
||
129 | * @param string Relative path to the template creating code for the HTML page body |
||
130 | * @since 2014.03 |
||
131 | * @category Developer |
||
132 | * @see client/html/basket/related/template-header |
||
133 | */ |
||
134 | |||
135 | /** client/html/basket/related/template-header |
||
136 | * Relative path to the HTML header template of the basket related client. |
||
137 | * |
||
138 | * The template file contains the HTML code and processing instructions |
||
139 | * to generate the HTML code that is inserted into the HTML page header |
||
140 | * of the rendered page in the frontend. The configuration string is the |
||
157 |