Skip to content

Commit aeccbe5

Browse files
committed
Add back extension point for adding some html to the category page #29286
1 parent 08671ba commit aeccbe5

File tree

2 files changed

+45
-24
lines changed
  • app/code/Magento

2 files changed

+45
-24
lines changed

app/code/Magento/Catalog/view/frontend/templates/product/list.phtml

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ use Magento\Framework\App\Action\Action;
88
?>
99
<?php
1010
// phpcs:disable Magento2.Templates.ThisInTemplate.FoundThis
11+
// phpcs:disable Magento2.Templates.ThisInTemplate.FoundHelper
12+
// phpcs:disable Generic.Files.LineLength.TooLong
1113

1214
/**
1315
* Product list template
@@ -21,13 +23,15 @@ $_productCollection = $block->getLoadedProductCollection();
2123
/** @var \Magento\Catalog\Helper\Output $_helper */
2224
$_helper = $this->helper(Magento\Catalog\Helper\Output::class);
2325
?>
24-
<?php if (!$_productCollection->count()) :?>
25-
<div class="message info empty"><div><?= $escaper->escapeHtml(__('We can\'t find products matching the selection.')) ?></div></div>
26-
<?php else :?>
26+
<?php if (!$_productCollection->count()): ?>
27+
<div class="message info empty">
28+
<div><?= $escaper->escapeHtml(__('We can\'t find products matching the selection.')) ?></div>
29+
</div>
30+
<?php else: ?>
2731
<?= $block->getToolbarHtml() ?>
2832
<?= $block->getAdditionalHtml() ?>
2933
<?php
30-
if ($block->getMode() == 'grid') {
34+
if ($block->getMode() === 'grid') {
3135
$viewMode = 'grid';
3236
$imageDisplayArea = 'category_page_grid';
3337
$showDescription = false;
@@ -46,7 +50,7 @@ $_helper = $this->helper(Magento\Catalog\Helper\Output::class);
4650
<div class="products wrapper <?= /* @noEscape */ $viewMode ?> products-<?= /* @noEscape */ $viewMode ?>">
4751
<ol class="products list items product-items">
4852
<?php /** @var $_product \Magento\Catalog\Model\Product */ ?>
49-
<?php foreach ($_productCollection as $_product) :?>
53+
<?php foreach ($_productCollection as $_product): ?>
5054
<li class="item product product-item">
5155
<div class="product-item-info" data-container="product-<?= /* @noEscape */ $viewMode ?>">
5256
<?php
@@ -63,13 +67,15 @@ $_helper = $this->helper(Magento\Catalog\Helper\Output::class);
6367
<?= $productImage->toHtml() ?>
6468
</a>
6569
<div class="product details product-item-details">
66-
<?php
67-
$_productNameStripped = $block->stripTags($_product->getName(), null, true);
68-
?>
70+
<?php $_productNameStripped = $block->stripTags($_product->getName(), null, true); ?>
6971
<strong class="product name product-item-name">
7072
<a class="product-item-link"
7173
href="<?= $escaper->escapeUrl($_product->getProductUrl()) ?>">
72-
<?= /* @noEscape */ $_helper->productAttribute($_product, $_product->getName(), 'name') ?>
74+
<?= /* @noEscape */ $_helper->productAttribute(
75+
$_product,
76+
$_product->getName(),
77+
'name'
78+
) ?>
7379
</a>
7480
</strong>
7581
<?= $block->getReviewsSummaryHtml($_product, $templateType) ?>
@@ -79,7 +85,7 @@ $_helper = $this->helper(Magento\Catalog\Helper\Output::class);
7985
<div class="product-item-inner">
8086
<div class="product actions product-item-actions"<?= strpos($pos, $viewMode . '-actions') ? $escaper->escapeHtmlAttr($position) : '' ?>>
8187
<div class="actions-primary"<?= strpos($pos, $viewMode . '-primary') ? $escaper->escapeHtmlAttr($position) : '' ?>>
82-
<?php if ($_product->isSaleable()) :?>
88+
<?php if ($_product->isSaleable()): ?>
8389
<?php $postParams = $block->getAddToCartPostParams($_product); ?>
8490
<form data-role="tocart-form"
8591
data-product-sku="<?= $escaper->escapeHtml($_product->getSku()) ?>"
@@ -88,7 +94,8 @@ $_helper = $this->helper(Magento\Catalog\Helper\Output::class);
8894
<input type="hidden"
8995
name="product"
9096
value="<?= /* @noEscape */ $postParams['data']['product'] ?>">
91-
<input type="hidden" name="<?= /* @noEscape */ Action::PARAM_NAME_URL_ENCODED ?>"
97+
<input type="hidden"
98+
name="<?= /* @noEscape */ Action::PARAM_NAME_URL_ENCODED ?>"
9299
value="<?= /* @noEscape */ $postParams['data'][Action::PARAM_NAME_URL_ENCODED] ?>">
93100
<?= $block->getBlockHtml('formkey') ?>
94101
<button type="submit"
@@ -97,23 +104,31 @@ $_helper = $this->helper(Magento\Catalog\Helper\Output::class);
97104
<span><?= $escaper->escapeHtml(__('Add to Cart')) ?></span>
98105
</button>
99106
</form>
100-
<?php else :?>
101-
<?php if ($_product->isAvailable()) :?>
102-
<div class="stock available"><span><?= $escaper->escapeHtml(__('In stock')) ?></span></div>
103-
<?php else :?>
104-
<div class="stock unavailable"><span><?= $escaper->escapeHtml(__('Out of stock')) ?></span></div>
107+
<?php else: ?>
108+
<?php if ($_product->isAvailable()): ?>
109+
<div class="stock available">
110+
<span><?= $escaper->escapeHtml(__('In stock')) ?></span>
111+
</div>
112+
<?php else: ?>
113+
<div class="stock unavailable">
114+
<span><?= $escaper->escapeHtml(__('Out of stock')) ?></span>
115+
</div>
105116
<?php endif; ?>
106117
<?php endif; ?>
107118
</div>
108119
<div data-role="add-to-links" class="actions-secondary"<?= strpos($pos, $viewMode . '-secondary') ? $escaper->escapeHtmlAttr($position) : '' ?>>
109-
<?php if ($addToBlock = $block->getChildBlock('addto')) :?>
120+
<?php if ($addToBlock = $block->getChildBlock('addto')): ?>
110121
<?= $addToBlock->setProduct($_product)->getChildHtml() ?>
111122
<?php endif; ?>
112123
</div>
113124
</div>
114-
<?php if ($showDescription) :?>
125+
<?php if ($showDescription): ?>
115126
<div class="product description product-item-description">
116-
<?= /* @noEscape */ $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
127+
<?= /* @noEscape */ $_helper->productAttribute(
128+
$_product,
129+
$_product->getShortDescription(),
130+
'short_description'
131+
) ?>
117132
<a href="<?= $escaper->escapeUrl($_product->getProductUrl()) ?>"
118133
title="<?= /* @noEscape */ $_productNameStripped ?>"
119134
class="action more"><?= $escaper->escapeHtml(__('Learn More')) ?></a>
@@ -127,7 +142,7 @@ $_helper = $this->helper(Magento\Catalog\Helper\Output::class);
127142
</ol>
128143
</div>
129144
<?= $block->getToolbarHtml() ?>
130-
<?php if (!$block->isRedirectToCartEnabled()) :?>
145+
<?php if (!$block->isRedirectToCartEnabled()): ?>
131146
<script type="text/x-magento-init">
132147
{
133148
"[data-role=tocart-form], .form.map.checkout": {

app/code/Magento/Swatches/view/frontend/templates/product/listing/renderer.phtml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
7+
use Magento\Catalog\Model\Product;
8+
use Magento\Swatches\Block\Product\Renderer\Listing\Configurable;
9+
use Magento\Swatches\ViewModel\Product\Renderer\Configurable as ConfigurableViewModel;
10+
11+
/** @var Configurable $block */
12+
/** @var Product $product */
13+
$product = $block->getProduct()
614
?>
7-
<?php /** @var $block \Magento\Swatches\Block\Product\Renderer\Listing\Configurable */ ?>
8-
<?php $product = $block->getProduct() ?>
9-
<?php if ($product && $product->isAvailable()) : ?>
15+
<?php if ($product && $product->isAvailable()): ?>
1016
<?php $productId = $product->getId() ?>
11-
<?php /** @var \Magento\Swatches\ViewModel\Product\Renderer\Configurable $configurableViewModel */ ?>
17+
<?php /** @var ConfigurableViewModel $configurableViewModel */ ?>
1218
<?php $configurableViewModel = $block->getConfigurableViewModel() ?>
1319
<div class="swatch-opt-<?= $block->escapeHtmlAttr($productId) ?>"
1420
data-role="swatch-option-<?= $block->escapeHtmlAttr($productId) ?>"></div>

0 commit comments

Comments
 (0)