Skip to content

Fix issue where upsell and related products were controlling each oth… #37482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: 2.4-develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2013 Adobe
* All Rights Reserved.
*/

use Magento\Catalog\ViewModel\Product\Listing\PreparePostData;
use Magento\Framework\App\ActionInterface;

/* @var $block \Magento\Catalog\Block\Product\AbstractProduct */
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
/**
* @var $block \Magento\Catalog\Block\Product\AbstractProduct
* @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
* @var Magento\Framework\Escaper $escaper
*/
?>

<?php
Expand Down Expand Up @@ -162,34 +165,36 @@ $_item = null;

<?php if ($type == 'related' || $type == 'upsell'):?>
<?php if ($type == 'related'):?>
<div class="block <?= $block->escapeHtmlAttr($class) ?>"
<div class="block <?= $escaper->escapeHtmlAttr($class) ?>"
data-mage-init='{"relatedProducts":{"relatedCheckbox":".related.checkbox"}}'
data-limit="<?= $block->escapeHtmlAttr($limit) ?>"
data-limit="<?= $escaper->escapeHtmlAttr($limit) ?>"
data-shuffle="<?= /* @noEscape */ $shuffle ?>"
data-shuffle-weighted="<?= /* @noEscape */ $isWeightedRandom ?>">
<?php else:?>
<div class="block <?= $block->escapeHtmlAttr($class) ?>"
<div class="block <?= $escaper->escapeHtmlAttr($class) ?>"
data-mage-init='{"upsellProducts":{}}'
data-limit="<?= $block->escapeHtmlAttr($limit) ?>"
data-limit="<?= $escaper->escapeHtmlAttr($limit) ?>"
data-shuffle="<?= /* @noEscape */ $shuffle ?>"
data-shuffle-weighted="<?= /* @noEscape */ $isWeightedRandom ?>">
<?php endif; ?>
<?php else:?>
<div class="block <?= $block->escapeHtmlAttr($class) ?>">
<div class="block <?= $escaper->escapeHtmlAttr($class) ?>">
<?php endif; ?>
<div class="block-title title">
<strong id="block-<?= $block->escapeHtmlAttr($class) ?>-heading" role="heading"
aria-level="2"><?= $block->escapeHtml($title) ?></strong>
<strong id="block-<?= $escaper->escapeHtmlAttr($class) ?>-heading" role="heading"
aria-level="2"><?= $escaper->escapeHtml($title) ?></strong>
</div>
<div class="block-content content" aria-labelledby="block-<?= $block->escapeHtmlAttr($class) ?>-heading">
<div class="block-content content" aria-labelledby="block-<?= $escaper->escapeHtmlAttr($class) ?>-heading">
<?php if ($type == 'related' && $canItemsAddToCart):?>
<div class="block-actions">
<?= $block->escapeHtml(__('Check items to add to the cart or')) ?>
<?= $escaper->escapeHtml(__('Check items to add to the cart or')) ?>
<button type="button" class="action select"
data-role="select-all"><span><?= $block->escapeHtml(__('select all')) ?></span></button>
data-role="select-all">
<span><?= $escaper->escapeHtml(__('select all')) ?></span>
</button>
</div>
<?php endif; ?>
<div class="products wrapper grid products-grid products-<?= $block->escapeHtmlAttr($type) ?>">
<div class="products wrapper grid products-grid products-<?= $escaper->escapeHtmlAttr($type) ?>">
<ol class="products list items product-items">
<?php foreach ($items as $_item):?>
<?php $available = ''; ?>
Expand All @@ -200,27 +205,27 @@ $_item = null;
<?php endif; ?>
<?php if ($type == 'related' || $type == 'upsell'):?>
<li class="item product product-item"
id="product-item_<?= /* @noEscape */ $_item->getId() ?>"
data-shuffle-group="<?= $block->escapeHtmlAttr($_item->getPriority()) ?>" >
id="product-item-<?= /* @noEscape */ $type ?>_<?= /* @noEscape */ $_item->getId() ?>"
data-shuffle-group="<?= $escaper->escapeHtmlAttr($_item->getPriority()) ?>" >
<?= /* @noEscape */ $secureRenderer->renderStyleAsTag(
'display:none;',
'li#product-item_' . $_item->getId()
'li#product-item-' . $type . '_' . $_item->getId()
) ?>
<?php else:?>
<li class="item product product-item">
<?php endif; ?>
<div class="product-item-info <?= /* @noEscape */ $available ?>">
<?= /* @noEscape */ '<!-- ' . $image . '-->' ?>
<a href="<?= $block->escapeUrl($block->getProductUrl($_item)) ?>"
<a href="<?= $escaper->escapeUrl($block->getProductUrl($_item)) ?>"
class="product photo product-item-photo">
<?= $block->getImage($_item, $image)->toHtml() ?>
</a>
<div class="product details product-item-details">
<strong class="product name product-item-name"><a
class="product-item-link"
title="<?= $block->escapeHtmlAttr($_item->getName()) ?>"
href="<?= $block->escapeUrl($block->getProductUrl($_item)) ?>">
<?= $block->escapeHtml($_item->getName()) ?></a>
title="<?= $escaper->escapeHtmlAttr($_item->getName()) ?>"
href="<?= $escaper->escapeUrl($block->getProductUrl($_item)) ?>">
<?= $escaper->escapeHtml($_item->getName()) ?></a>
</strong>

<?= /* @noEscape */ $block->getProductPrice($_item) ?>
Expand All @@ -236,12 +241,16 @@ $_item = null;
<input
type="checkbox"
class="checkbox related"
id="related-checkbox<?= $block->escapeHtmlAttr($_item->getId()) ?>"
id="related-checkbox<?=
$escaper->escapeHtmlAttr($_item->getId())
?>"
name="related_products[]"
value="<?= $block->escapeHtmlAttr($_item->getId()) ?>" />
value="<?= $escaper->escapeHtmlAttr($_item->getId()) ?>" />
<label class="label"
for="related-checkbox<?= $block->escapeHtmlAttr($_item->getId())
?>"><span><?= $block->escapeHtml(__('Add to Cart')) ?></span>
for="related-checkbox<?=
$escaper->escapeHtmlAttr($_item->getId())
?>">
<span><?= $escaper->escapeHtml(__('Add to Cart')) ?></span>
</label>
</div>
<?php endif; ?>
Expand Down Expand Up @@ -324,7 +333,7 @@ $_item = null;
{
"[data-role=tocart-form], .form.map.checkout": {
"catalogAddToCart": {
"product_sku": "<?= $block->escapeJs($_item->getSku()) ?>"
"product_sku": "<?= $escaper->escapeJs($_item->getSku()) ?>"
}
}
}
Expand Down