6
6
7
7
// phpcs:disable Magento2.Templates.ThisInTemplate.FoundThis
8
8
// phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect
9
+ // phpcs:disable Generic.Files.LineLength
10
+ // phpcs:disable Magento2.Templates.ThisInTemplate.FoundHelper
9
11
10
12
/* @var $block \Magento\Catalog\Block\Product\AbstractProduct */
11
13
?>
@@ -23,6 +25,7 @@ switch ($type = $block->getType()) {
23
25
$ items = $ block ->getAllItems ();
24
26
$ limit = $ block ->getPositionLimit ();
25
27
$ shuffle = (int ) $ block ->isShuffled ();
28
+ $ isWeightedRandom = (int ) $ block ->getRotation ()->isWeightedRandom ($ block ->getProductListType ());
26
29
$ canItemsAddToCart = $ block ->canItemsAddToCart ();
27
30
28
31
$ showAddTo = true ;
@@ -43,6 +46,7 @@ switch ($type = $block->getType()) {
43
46
$ items = $ block ->getItems ();
44
47
$ limit = 0 ;
45
48
$ shuffle = 0 ;
49
+ $ isWeightedRandom = 0 ;
46
50
$ canItemsAddToCart = $ block ->canItemsAddToCart ();
47
51
48
52
$ showAddTo = true ;
@@ -62,6 +66,7 @@ switch ($type = $block->getType()) {
62
66
$ items = $ block ->getAllItems ();
63
67
$ limit = $ block ->getPositionLimit ();
64
68
$ shuffle = (int ) $ block ->isShuffled ();
69
+ $ isWeightedRandom = (int ) $ block ->getRotation ()->isWeightedRandom ($ block ->getProductListType ());
65
70
66
71
$ showAddTo = false ;
67
72
$ showCart = false ;
@@ -82,6 +87,7 @@ switch ($type = $block->getType()) {
82
87
$ items = $ block ->getItemCollection ()->getItems ();
83
88
$ limit = $ block ->getItemLimit ('upsell ' );
84
89
$ shuffle = 0 ;
90
+ $ isWeightedRandom = 0 ;
85
91
86
92
$ showAddTo = false ;
87
93
$ showCart = false ;
@@ -152,39 +158,39 @@ switch ($type = $block->getType()) {
152
158
}
153
159
?>
154
160
155
- <?php if ($ exist ) :?>
161
+ <?php if ($ exist ):?>
156
162
157
- <?php if ($ type == 'related ' || $ type == 'upsell ' ) :?>
158
- <?php if ($ type == 'related ' ) :?>
159
- <div class="block <?= $ block ->escapeHtmlAttr ($ class ) ?> " data-mage-init='{"relatedProducts":{"relatedCheckbox":".related.checkbox"}}' data-limit="<?= $ block ->escapeHtmlAttr ($ limit ) ?> " data-shuffle="<?= /* @noEscape */ $ shuffle ?> ">
160
- <?php else :?>
161
- <div class="block <?= $ block ->escapeHtmlAttr ($ class ) ?> " data-mage-init='{"upsellProducts":{}}' data-limit="<?= $ block ->escapeHtmlAttr ($ limit ) ?> " data-shuffle="<?= /* @noEscape */ $ shuffle ?> ">
163
+ <?php if ($ type == 'related ' || $ type == 'upsell ' ):?>
164
+ <?php if ($ type == 'related ' ):?>
165
+ <div class="block <?= $ block ->escapeHtmlAttr ($ class ) ?> " data-mage-init='{"relatedProducts":{"relatedCheckbox":".related.checkbox"}}' data-limit="<?= $ block ->escapeHtmlAttr ($ limit ) ?> " data-shuffle="<?= /* @noEscape */ $ shuffle ?> " data-shuffle-weighted=" <?= /* @noEscape */ $ isWeightedRandom ?> " >
166
+ <?php else :?>
167
+ <div class="block <?= $ block ->escapeHtmlAttr ($ class ) ?> " data-mage-init='{"upsellProducts":{}}' data-limit="<?= $ block ->escapeHtmlAttr ($ limit ) ?> " data-shuffle="<?= /* @noEscape */ $ shuffle ?> " data-shuffle-weighted=" <?= /* @noEscape */ $ isWeightedRandom ?> " >
162
168
<?php endif ; ?>
163
- <?php else :?>
169
+ <?php else :?>
164
170
<div class="block <?= $ block ->escapeHtmlAttr ($ class ) ?> ">
165
171
<?php endif ; ?>
166
172
<div class="block-title title">
167
173
<strong id="block-<?= $ block ->escapeHtmlAttr ($ class ) ?> -heading" role="heading" aria-level="2"><?= $ block ->escapeHtml ($ title ) ?> </strong>
168
174
</div>
169
175
<div class="block-content content" aria-labelledby="block-<?= $ block ->escapeHtmlAttr ($ class ) ?> -heading">
170
- <?php if ($ type == 'related ' && $ canItemsAddToCart ) :?>
176
+ <?php if ($ type == 'related ' && $ canItemsAddToCart ):?>
171
177
<div class="block-actions">
172
178
<?= $ block ->escapeHtml (__ ('Check items to add to the cart or ' )) ?>
173
179
<button type="button" class="action select" data-role="select-all"><span><?= $ block ->escapeHtml (__ ('select all ' )) ?> </span></button>
174
180
</div>
175
181
<?php endif ; ?>
176
182
<div class="products wrapper grid products-grid products-<?= $ block ->escapeHtmlAttr ($ type ) ?> ">
177
183
<ol class="products list items product-items">
178
- <?php foreach ($ items as $ _item ) :?>
184
+ <?php foreach ($ items as $ _item ):?>
179
185
<?php $ available = '' ; ?>
180
- <?php if (!$ _item ->isComposite () && $ _item ->isSaleable () && $ type == 'related ' ) :?>
181
- <?php if (!$ _item ->getRequiredOptions ()) :?>
186
+ <?php if (!$ _item ->isComposite () && $ _item ->isSaleable () && $ type == 'related ' ):?>
187
+ <?php if (!$ _item ->getRequiredOptions ()):?>
182
188
<?php $ available = 'related-available ' ; ?>
183
189
<?php endif ; ?>
184
190
<?php endif ; ?>
185
- <?php if ($ type == 'related ' || $ type == 'upsell ' ) :?>
186
- <li class="item product product-item" style="display: none;">
187
- <?php else :?>
191
+ <?php if ($ type == 'related ' || $ type == 'upsell ' ):?>
192
+ <li class="item product product-item" style="display: none;" data-shuffle-group=" <?= $ block -> escapeHtmlAttr ( $ _item -> getPriority ()) ?> " >
193
+ <?php else :?>
188
194
<li class="item product product-item">
189
195
<?php endif ; ?>
190
196
<div class="product-item-info <?= /* @noEscape */ $ available ?> ">
@@ -199,29 +205,29 @@ switch ($type = $block->getType()) {
199
205
200
206
<?= /* @noEscape */ $ block ->getProductPrice ($ _item ) ?>
201
207
202
- <?php if ($ templateType ) :?>
208
+ <?php if ($ templateType ):?>
203
209
<?= $ block ->getReviewsSummaryHtml ($ _item , $ templateType ) ?>
204
210
<?php endif ; ?>
205
211
206
- <?php if ($ canItemsAddToCart && !$ _item ->isComposite () && $ _item ->isSaleable () && $ type == 'related ' ) :?>
207
- <?php if (!$ _item ->getRequiredOptions ()) :?>
212
+ <?php if ($ canItemsAddToCart && !$ _item ->isComposite () && $ _item ->isSaleable () && $ type == 'related ' ):?>
213
+ <?php if (!$ _item ->getRequiredOptions ()):?>
208
214
<div class="field choice related">
209
215
<input type="checkbox" class="checkbox related" id="related-checkbox<?= $ block ->escapeHtmlAttr ($ _item ->getId ()) ?> " name="related_products[]" value="<?= $ block ->escapeHtmlAttr ($ _item ->getId ()) ?> " />
210
216
<label class="label" for="related-checkbox<?= $ block ->escapeHtmlAttr ($ _item ->getId ()) ?> "><span><?= $ block ->escapeHtml (__ ('Add to Cart ' )) ?> </span></label>
211
217
</div>
212
218
<?php endif ; ?>
213
219
<?php endif ; ?>
214
220
215
- <?php if ($ showAddTo || $ showCart ) :?>
221
+ <?php if ($ showAddTo || $ showCart ):?>
216
222
<div class="product actions product-item-actions">
217
- <?php if ($ showCart ) :?>
223
+ <?php if ($ showCart ):?>
218
224
<div class="actions-primary">
219
- <?php if ($ _item ->isSaleable ()) :?>
220
- <?php if ($ _item ->getTypeInstance ()->hasRequiredOptions ($ _item )) :?>
225
+ <?php if ($ _item ->isSaleable ()):?>
226
+ <?php if ($ _item ->getTypeInstance ()->hasRequiredOptions ($ _item )):?>
221
227
<button class="action tocart primary" data-mage-init='{"redirectUrl": {"url": "<?= $ block ->escapeUrl ($ block ->getAddToCartUrl ($ _item )) ?> "}}' type="button" title="<?= $ block ->escapeHtmlAttr (__ ('Add to Cart ' )) ?> ">
222
228
<span><?= $ block ->escapeHtml (__ ('Add to Cart ' )) ?> </span>
223
229
</button>
224
- <?php else :?>
230
+ <?php else :?>
225
231
<?php $ postDataHelper = $ this ->helper (Magento \Framework \Data \Helper \PostHelper::class);
226
232
$ postData = $ postDataHelper ->getPostData ($ block ->escapeUrl ($ block ->getAddToCartUrl ($ _item )), ['product ' => $ _item ->getEntityId ()])
227
233
?>
@@ -231,19 +237,19 @@ switch ($type = $block->getType()) {
231
237
<span><?= $ block ->escapeHtml (__ ('Add to Cart ' )) ?> </span>
232
238
</button>
233
239
<?php endif ; ?>
234
- <?php else :?>
235
- <?php if ($ _item ->getIsSalable ()) :?>
240
+ <?php else :?>
241
+ <?php if ($ _item ->getIsSalable ()):?>
236
242
<div class="stock available"><span><?= $ block ->escapeHtml (__ ('In stock ' )) ?> </span></div>
237
- <?php else :?>
243
+ <?php else :?>
238
244
<div class="stock unavailable"><span><?= $ block ->escapeHtml (__ ('Out of stock ' )) ?> </span></div>
239
245
<?php endif ; ?>
240
246
<?php endif ; ?>
241
247
</div>
242
248
<?php endif ; ?>
243
249
244
- <?php if ($ showAddTo ) :?>
250
+ <?php if ($ showAddTo ):?>
245
251
<div class="secondary-addto-links actions-secondary" data-role="add-to-links">
246
- <?php if ($ addToBlock = $ block ->getChildBlock ('addto ' )) :?>
252
+ <?php if ($ addToBlock = $ block ->getChildBlock ('addto ' )):?>
247
253
<?= $ addToBlock ->setProduct ($ _item )->getChildHtml () ?>
248
254
<?php endif ; ?>
249
255
</div>
0 commit comments