Skip to content

Commit bfc1c5a

Browse files
committed
Merge remote-tracking branch 'l3/MC-39107' into PR-01-21
2 parents b7d0027 + 4f6cf60 commit bfc1c5a

File tree

1 file changed

+26
-13
lines changed
  • app/code/Magento/CatalogWidget/view/frontend/templates/product/widget/content

1 file changed

+26
-13
lines changed

app/code/Magento/CatalogWidget/view/frontend/templates/product/widget/content/grid.phtml

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
use Magento\Framework\App\Action\Action;
78

89
/** @var \Magento\CatalogWidget\Block\Product\ProductsList $block */
10+
11+
// phpcs:disable Generic.Files.LineLength.TooLong
12+
// phpcs:disable Magento2.Templates.ThisInTemplate.FoundHelper
913
?>
10-
<?php if ($exist = ($block->getProductCollection() && $block->getProductCollection()->getSize())) : ?>
14+
<?php if ($exist = ($block->getProductCollection() && $block->getProductCollection()->getSize())): ?>
1115
<?php
1216
$type = 'widget-product-grid';
1317

@@ -23,7 +27,7 @@ use Magento\Framework\App\Action\Action;
2327
$description = false;
2428
?>
2529
<div class="block widget block-products-list <?= /* @noEscape */ $mode ?>">
26-
<?php if ($block->getTitle()) : ?>
30+
<?php if ($block->getTitle()): ?>
2731
<div class="block-title">
2832
<strong><?= $block->escapeHtml(__($block->getTitle())) ?></strong>
2933
</div>
@@ -33,7 +37,7 @@ use Magento\Framework\App\Action\Action;
3337
<div class="products-<?= /* @noEscape */ $mode ?> <?= /* @noEscape */ $mode ?>">
3438
<ol class="product-items <?= /* @noEscape */ $type ?>">
3539
<?php $iterator = 1; ?>
36-
<?php foreach ($items as $_item) : ?>
40+
<?php foreach ($items as $_item): ?>
3741
<?= /* @noEscape */ ($iterator++ == 1) ? '<li class="product-item">' : '</li><li class="product-item">' ?>
3842
<div class="product-item-info">
3943
<a href="<?= $block->escapeUrl($block->getProductUrl($_item)) ?>" class="product-item-photo">
@@ -47,20 +51,20 @@ use Magento\Framework\App\Action\Action;
4751
<?= $block->escapeHtml($_item->getName()) ?>
4852
</a>
4953
</strong>
50-
<?php if ($templateType) : ?>
54+
<?php if ($templateType): ?>
5155
<?= $block->getReviewsSummaryHtml($_item, $templateType) ?>
5256
<?php endif; ?>
5357

5458
<?= $block->getProductPriceHtml($_item, $type) ?>
5559

5660
<?= $block->getProductDetailsHtml($_item) ?>
5761

58-
<?php if ($showWishlist || $showCompare || $showCart) : ?>
62+
<?php if ($showWishlist || $showCompare || $showCart): ?>
5963
<div class="product-item-inner">
6064
<div class="product-item-actions">
61-
<?php if ($showCart) : ?>
65+
<?php if ($showCart): ?>
6266
<div class="actions-primary">
63-
<?php if ($_item->isSaleable()) : ?>
67+
<?php if ($_item->isSaleable()): ?>
6468
<?php $postParams = $block->getAddToCartPostParams($_item); ?>
6569
<form data-role="tocart-form" data-product-sku="<?= $block->escapeHtml($_item->getSku()) ?>" action="<?= $block->escapeUrl($postParams['action']) ?>" method="post">
6670
<input type="hidden" name="product" value="<?= $block->escapeHtmlAttr($postParams['data']['product']) ?>">
@@ -72,24 +76,24 @@ use Magento\Framework\App\Action\Action;
7276
<span><?= $block->escapeHtml(__('Add to Cart')) ?></span>
7377
</button>
7478
</form>
75-
<?php else : ?>
76-
<?php if ($_item->getIsSalable()) : ?>
79+
<?php else: ?>
80+
<?php if ($_item->getIsSalable()): ?>
7781
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
78-
<?php else : ?>
82+
<?php else: ?>
7983
<div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>
8084
<?php endif; ?>
8185
<?php endif; ?>
8286
</div>
8387
<?php endif; ?>
84-
<?php if ($showWishlist || $showCompare) : ?>
88+
<?php if ($showWishlist || $showCompare): ?>
8589
<div class="actions-secondary" data-role="add-to-links">
86-
<?php if ($this->helper(\Magento\Wishlist\Helper\Data::class)->isAllow() && $showWishlist) : ?>
90+
<?php if ($this->helper(\Magento\Wishlist\Helper\Data::class)->isAllow() && $showWishlist): ?>
8791
<a href="#"
8892
data-post='<?= /* @noEscape */ $block->getAddToWishlistParams($_item) ?>' class="action towishlist" data-action="add-to-wishlist" title="<?= $block->escapeHtmlAttr(__('Add to Wish List')) ?>">
8993
<span><?= $block->escapeHtml(__('Add to Wish List')) ?></span>
9094
</a>
9195
<?php endif; ?>
92-
<?php if ($block->getAddToCompareUrl() && $showCompare) : ?>
96+
<?php if ($block->getAddToCompareUrl() && $showCompare): ?>
9397
<?php $compareHelper = $this->helper(\Magento\Catalog\Helper\Product\Compare::class);?>
9498
<a href="#" class="action tocompare" data-post='<?= /* @noEscape */ $compareHelper->getPostDataParams($_item) ?>' title="<?= $block->escapeHtmlAttr(__('Add to Compare')) ?>">
9599
<span><?= $block->escapeHtml(__('Add to Compare')) ?></span>
@@ -109,4 +113,13 @@ use Magento\Framework\App\Action\Action;
109113
<?= $block->getPagerHtml() ?>
110114
</div>
111115
</div>
116+
<?php if($block->getBlockHtml('formkey')): ?>
117+
<script type="text/x-magento-init">
118+
{
119+
".block.widget [data-role=tocart-form]": {
120+
"Magento_Catalog/js/validate-product": {}
121+
}
122+
}
123+
</script>
124+
<?php endif;?>
112125
<?php endif;?>

0 commit comments

Comments
 (0)