66
77// phpcs:disable Magento2.Templates.ThisInTemplate.FoundThis
88// phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect
9+ // phpcs:disable Generic.Files.LineLength
10+ // phpcs:disable Magento2.Templates.ThisInTemplate.FoundHelper
911
1012/* @var $block \Magento\Catalog\Block\Product\AbstractProduct */
1113?>
@@ -23,6 +25,7 @@ switch ($type = $block->getType()) {
2325 $ items = $ block ->getAllItems ();
2426 $ limit = $ block ->getPositionLimit ();
2527 $ shuffle = (int ) $ block ->isShuffled ();
28+ $ isWeightedRandom = (int ) $ block ->getRotation ()->isWeightedRandom ($ block ->getProductListType ());
2629 $ canItemsAddToCart = $ block ->canItemsAddToCart ();
2730
2831 $ showAddTo = true ;
@@ -43,6 +46,7 @@ switch ($type = $block->getType()) {
4346 $ items = $ block ->getItems ();
4447 $ limit = 0 ;
4548 $ shuffle = 0 ;
49+ $ isWeightedRandom = 0 ;
4650 $ canItemsAddToCart = $ block ->canItemsAddToCart ();
4751
4852 $ showAddTo = true ;
@@ -62,6 +66,7 @@ switch ($type = $block->getType()) {
6266 $ items = $ block ->getAllItems ();
6367 $ limit = $ block ->getPositionLimit ();
6468 $ shuffle = (int ) $ block ->isShuffled ();
69+ $ isWeightedRandom = (int ) $ block ->getRotation ()->isWeightedRandom ($ block ->getProductListType ());
6570
6671 $ showAddTo = false ;
6772 $ showCart = false ;
@@ -82,6 +87,7 @@ switch ($type = $block->getType()) {
8287 $ items = $ block ->getItemCollection ()->getItems ();
8388 $ limit = $ block ->getItemLimit ('upsell ' );
8489 $ shuffle = 0 ;
90+ $ isWeightedRandom = 0 ;
8591
8692 $ showAddTo = false ;
8793 $ showCart = false ;
@@ -152,39 +158,39 @@ switch ($type = $block->getType()) {
152158}
153159?>
154160
155- <?php if ($ exist ) :?>
161+ <?php if ($ exist ):?>
156162
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 ?> " >
162168 <?php endif ; ?>
163- <?php else :?>
169+ <?php else :?>
164170 <div class="block <?= $ block ->escapeHtmlAttr ($ class ) ?> ">
165171 <?php endif ; ?>
166172 <div class="block-title title">
167173 <strong id="block-<?= $ block ->escapeHtmlAttr ($ class ) ?> -heading" role="heading" aria-level="2"><?= $ block ->escapeHtml ($ title ) ?> </strong>
168174 </div>
169175 <div class="block-content content" aria-labelledby="block-<?= $ block ->escapeHtmlAttr ($ class ) ?> -heading">
170- <?php if ($ type == 'related ' && $ canItemsAddToCart ) :?>
176+ <?php if ($ type == 'related ' && $ canItemsAddToCart ):?>
171177 <div class="block-actions">
172178 <?= $ block ->escapeHtml (__ ('Check items to add to the cart or ' )) ?>
173179 <button type="button" class="action select" data-role="select-all"><span><?= $ block ->escapeHtml (__ ('select all ' )) ?> </span></button>
174180 </div>
175181 <?php endif ; ?>
176182 <div class="products wrapper grid products-grid products-<?= $ block ->escapeHtmlAttr ($ type ) ?> ">
177183 <ol class="products list items product-items">
178- <?php foreach ($ items as $ _item ) :?>
184+ <?php foreach ($ items as $ _item ):?>
179185 <?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 ()):?>
182188 <?php $ available = 'related-available ' ; ?>
183189 <?php endif ; ?>
184190 <?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 :?>
188194 <li class="item product product-item">
189195 <?php endif ; ?>
190196 <div class="product-item-info <?= /* @noEscape */ $ available ?> ">
@@ -199,29 +205,29 @@ switch ($type = $block->getType()) {
199205
200206 <?= /* @noEscape */ $ block ->getProductPrice ($ _item ) ?>
201207
202- <?php if ($ templateType ) :?>
208+ <?php if ($ templateType ):?>
203209 <?= $ block ->getReviewsSummaryHtml ($ _item , $ templateType ) ?>
204210 <?php endif ; ?>
205211
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 ()):?>
208214 <div class="field choice related">
209215 <input type="checkbox" class="checkbox related" id="related-checkbox<?= $ block ->escapeHtmlAttr ($ _item ->getId ()) ?> " name="related_products[]" value="<?= $ block ->escapeHtmlAttr ($ _item ->getId ()) ?> " />
210216 <label class="label" for="related-checkbox<?= $ block ->escapeHtmlAttr ($ _item ->getId ()) ?> "><span><?= $ block ->escapeHtml (__ ('Add to Cart ' )) ?> </span></label>
211217 </div>
212218 <?php endif ; ?>
213219 <?php endif ; ?>
214220
215- <?php if ($ showAddTo || $ showCart ) :?>
221+ <?php if ($ showAddTo || $ showCart ):?>
216222 <div class="product actions product-item-actions">
217- <?php if ($ showCart ) :?>
223+ <?php if ($ showCart ):?>
218224 <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 )):?>
221227 <button class="action tocart primary" data-mage-init='{"redirectUrl": {"url": "<?= $ block ->escapeUrl ($ block ->getAddToCartUrl ($ _item )) ?> "}}' type="button" title="<?= $ block ->escapeHtmlAttr (__ ('Add to Cart ' )) ?> ">
222228 <span><?= $ block ->escapeHtml (__ ('Add to Cart ' )) ?> </span>
223229 </button>
224- <?php else :?>
230+ <?php else :?>
225231 <?php $ postDataHelper = $ this ->helper (Magento \Framework \Data \Helper \PostHelper::class);
226232 $ postData = $ postDataHelper ->getPostData ($ block ->escapeUrl ($ block ->getAddToCartUrl ($ _item )), ['product ' => $ _item ->getEntityId ()])
227233 ?>
@@ -231,19 +237,19 @@ switch ($type = $block->getType()) {
231237 <span><?= $ block ->escapeHtml (__ ('Add to Cart ' )) ?> </span>
232238 </button>
233239 <?php endif ; ?>
234- <?php else :?>
235- <?php if ($ _item ->getIsSalable ()) :?>
240+ <?php else :?>
241+ <?php if ($ _item ->getIsSalable ()):?>
236242 <div class="stock available"><span><?= $ block ->escapeHtml (__ ('In stock ' )) ?> </span></div>
237- <?php else :?>
243+ <?php else :?>
238244 <div class="stock unavailable"><span><?= $ block ->escapeHtml (__ ('Out of stock ' )) ?> </span></div>
239245 <?php endif ; ?>
240246 <?php endif ; ?>
241247 </div>
242248 <?php endif ; ?>
243249
244- <?php if ($ showAddTo ) :?>
250+ <?php if ($ showAddTo ):?>
245251 <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 ' )):?>
247253 <?= $ addToBlock ->setProduct ($ _item )->getChildHtml () ?>
248254 <?php endif ; ?>
249255 </div>
0 commit comments