3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+
6
7
use Magento \Framework \App \Action \Action ;
7
8
8
9
/** @var \Magento\CatalogWidget\Block\Product\ProductsList $block */
10
+
11
+ // phpcs:disable Generic.Files.LineLength.TooLong
12
+ // phpcs:disable Magento2.Templates.ThisInTemplate.FoundHelper
9
13
?>
10
- <?php if ($ exist = ($ block ->getProductCollection () && $ block ->getProductCollection ()->getSize ())) : ?>
14
+ <?php if ($ exist = ($ block ->getProductCollection () && $ block ->getProductCollection ()->getSize ())): ?>
11
15
<?php
12
16
$ type = 'widget-product-grid ' ;
13
17
@@ -23,7 +27,7 @@ use Magento\Framework\App\Action\Action;
23
27
$ description = false ;
24
28
?>
25
29
<div class="block widget block-products-list <?= /* @noEscape */ $ mode ?> ">
26
- <?php if ($ block ->getTitle ()) : ?>
30
+ <?php if ($ block ->getTitle ()): ?>
27
31
<div class="block-title">
28
32
<strong><?= $ block ->escapeHtml (__ ($ block ->getTitle ())) ?> </strong>
29
33
</div>
@@ -33,7 +37,7 @@ use Magento\Framework\App\Action\Action;
33
37
<div class="products-<?= /* @noEscape */ $ mode ?> <?= /* @noEscape */ $ mode ?> ">
34
38
<ol class="product-items <?= /* @noEscape */ $ type ?> ">
35
39
<?php $ iterator = 1 ; ?>
36
- <?php foreach ($ items as $ _item ) : ?>
40
+ <?php foreach ($ items as $ _item ): ?>
37
41
<?= /* @noEscape */ ($ iterator ++ == 1 ) ? '<li class="product-item"> ' : '</li><li class="product-item"> ' ?>
38
42
<div class="product-item-info">
39
43
<a href="<?= $ block ->escapeUrl ($ block ->getProductUrl ($ _item )) ?> " class="product-item-photo">
@@ -47,20 +51,20 @@ use Magento\Framework\App\Action\Action;
47
51
<?= $ block ->escapeHtml ($ _item ->getName ()) ?>
48
52
</a>
49
53
</strong>
50
- <?php if ($ templateType ) : ?>
54
+ <?php if ($ templateType ): ?>
51
55
<?= $ block ->getReviewsSummaryHtml ($ _item , $ templateType ) ?>
52
56
<?php endif ; ?>
53
57
54
58
<?= $ block ->getProductPriceHtml ($ _item , $ type ) ?>
55
59
56
60
<?= $ block ->getProductDetailsHtml ($ _item ) ?>
57
61
58
- <?php if ($ showWishlist || $ showCompare || $ showCart ) : ?>
62
+ <?php if ($ showWishlist || $ showCompare || $ showCart ): ?>
59
63
<div class="product-item-inner">
60
64
<div class="product-item-actions">
61
- <?php if ($ showCart ) : ?>
65
+ <?php if ($ showCart ): ?>
62
66
<div class="actions-primary">
63
- <?php if ($ _item ->isSaleable ()) : ?>
67
+ <?php if ($ _item ->isSaleable ()): ?>
64
68
<?php $ postParams = $ block ->getAddToCartPostParams ($ _item ); ?>
65
69
<form data-role="tocart-form" data-product-sku="<?= $ block ->escapeHtml ($ _item ->getSku ()) ?> " action="<?= $ block ->escapeUrl ($ postParams ['action ' ]) ?> " method="post">
66
70
<input type="hidden" name="product" value="<?= $ block ->escapeHtmlAttr ($ postParams ['data ' ]['product ' ]) ?> ">
@@ -72,24 +76,24 @@ use Magento\Framework\App\Action\Action;
72
76
<span><?= $ block ->escapeHtml (__ ('Add to Cart ' )) ?> </span>
73
77
</button>
74
78
</form>
75
- <?php else : ?>
76
- <?php if ($ _item ->getIsSalable ()) : ?>
79
+ <?php else : ?>
80
+ <?php if ($ _item ->getIsSalable ()): ?>
77
81
<div class="stock available"><span><?= $ block ->escapeHtml (__ ('In stock ' )) ?> </span></div>
78
- <?php else : ?>
82
+ <?php else : ?>
79
83
<div class="stock unavailable"><span><?= $ block ->escapeHtml (__ ('Out of stock ' )) ?> </span></div>
80
84
<?php endif ; ?>
81
85
<?php endif ; ?>
82
86
</div>
83
87
<?php endif ; ?>
84
- <?php if ($ showWishlist || $ showCompare ) : ?>
88
+ <?php if ($ showWishlist || $ showCompare ): ?>
85
89
<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 ): ?>
87
91
<a href="#"
88
92
data-post='<?= /* @noEscape */ $ block ->getAddToWishlistParams ($ _item ) ?> ' class="action towishlist" data-action="add-to-wishlist" title="<?= $ block ->escapeHtmlAttr (__ ('Add to Wish List ' )) ?> ">
89
93
<span><?= $ block ->escapeHtml (__ ('Add to Wish List ' )) ?> </span>
90
94
</a>
91
95
<?php endif ; ?>
92
- <?php if ($ block ->getAddToCompareUrl () && $ showCompare ) : ?>
96
+ <?php if ($ block ->getAddToCompareUrl () && $ showCompare ): ?>
93
97
<?php $ compareHelper = $ this ->helper (\Magento \Catalog \Helper \Product \Compare::class);?>
94
98
<a href="#" class="action tocompare" data-post='<?= /* @noEscape */ $ compareHelper ->getPostDataParams ($ _item ) ?> ' title="<?= $ block ->escapeHtmlAttr (__ ('Add to Compare ' )) ?> ">
95
99
<span><?= $ block ->escapeHtml (__ ('Add to Compare ' )) ?> </span>
@@ -109,4 +113,13 @@ use Magento\Framework\App\Action\Action;
109
113
<?= $ block ->getPagerHtml () ?>
110
114
</div>
111
115
</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 ;?>
112
125
<?php endif ;?>
0 commit comments