4
4
* See COPYING.txt for license details.
5
5
*/
6
6
7
+ use Magento \Catalog \Block \Product \ReviewRendererInterface ;
8
+ use Magento \Catalog \Helper \Product \Compare ;
9
+ use Magento \CatalogWidget \Block \Product \ProductsList ;
7
10
use Magento \Framework \App \Action \Action ;
11
+ use Magento \Framework \Escaper ;
12
+ use Magento \Wishlist \Helper \Data ;
8
13
9
- /**
10
- * @var \Magento\CatalogWidget\Block\Product\ProductsList $block
11
- * @var \Magento\Framework\Escaper $escaper
12
- */
14
+ /** @var Escaper $escaper */
15
+ /** @var ProductsList $block */
13
16
14
17
// phpcs:disable Generic.Files.LineLength.TooLong
15
18
// phpcs:disable Magento2.Templates.ThisInTemplate.FoundHelper
@@ -27,13 +30,13 @@ use Magento\Framework\App\Action\Action;
27
30
$ showWishlist = true ;
28
31
$ showCompare = true ;
29
32
$ showCart = true ;
30
- $ templateType = \ Magento \ Catalog \ Block \ Product \ ReviewRendererInterface::SHORT_VIEW ;
33
+ $ templateType = ReviewRendererInterface::SHORT_VIEW ;
31
34
$ description = false ;
32
35
?>
33
36
<div class="block widget block-products-list <?= /* @noEscape */ $ mode ?> ">
34
37
<?php if ($ block ->getTitle ()): ?>
35
38
<div class="block-title">
36
- <strong><?= $ block ->escapeHtml (__ ($ block ->getTitle ())) ?> </strong>
39
+ <strong><?= $ escaper ->escapeHtml (__ ($ block ->getTitle ())) ?> </strong>
37
40
</div>
38
41
<?php endif ?>
39
42
<div class="block-content">
@@ -44,15 +47,15 @@ use Magento\Framework\App\Action\Action;
44
47
<?php foreach ($ items as $ _item ): ?>
45
48
<?= /* @noEscape */ ($ iterator ++ == 1 ) ? '<li class="product-item"> ' : '</li><li class="product-item"> ' ?>
46
49
<div class="product-item-info">
47
- <a href="<?= $ block ->escapeUrl ($ block ->getProductUrl ($ _item )) ?> " class="product-item-photo">
50
+ <a href="<?= $ escaper ->escapeUrl ($ block ->getProductUrl ($ _item )) ?> " class="product-item-photo">
48
51
<?= $ block ->getImage ($ _item , $ image )->toHtml () ?>
49
52
</a>
50
53
<div class="product-item-details">
51
54
<strong class="product-item-name">
52
- <a title="<?= $ block ->escapeHtml ($ _item ->getName ()) ?> "
53
- href="<?= $ block ->escapeUrl ($ block ->getProductUrl ($ _item )) ?> "
55
+ <a title="<?= $ escaper ->escapeHtml ($ _item ->getName ()) ?> "
56
+ href="<?= $ escaper ->escapeUrl ($ block ->getProductUrl ($ _item )) ?> "
54
57
class="product-item-link">
55
- <?= $ block ->escapeHtml ($ _item ->getName ()) ?>
58
+ <?= $ escaper ->escapeHtml ($ _item ->getName ()) ?>
56
59
</a>
57
60
</strong>
58
61
<?php if ($ templateType ): ?>
@@ -70,14 +73,14 @@ use Magento\Framework\App\Action\Action;
70
73
<div class="actions-primary">
71
74
<?php if ($ _item ->isSaleable ()): ?>
72
75
<?php $ postParams = $ block ->getAddToCartPostParams ($ _item ); ?>
73
- <form data-role="tocart-form" data-product-sku="<?= $ block ->escapeHtml ($ _item ->getSku ()) ?> " action="<?= $ block ->escapeUrl ($ postParams ['action ' ]) ?> " method="post">
74
- <input type="hidden" name="product" value="<?= $ block ->escapeHtmlAttr ($ postParams ['data ' ]['product ' ]) ?> ">
76
+ <form data-role="tocart-form" data-product-sku="<?= $ escaper ->escapeHtml ($ _item ->getSku ()) ?> " action="<?= $ escaper ->escapeUrl ($ postParams ['action ' ]) ?> " method="post">
77
+ <input type="hidden" name="product" value="<?= $ escaper ->escapeHtmlAttr ($ postParams ['data ' ]['product ' ]) ?> ">
75
78
<input type="hidden" name="<?= /* @noEscape */ Action::PARAM_NAME_URL_ENCODED ?> " value="<?= /* @noEscape */ $ postParams ['data ' ][Action::PARAM_NAME_URL_ENCODED ] ?> ">
76
79
<?= $ block ->getBlockHtml ('formkey ' ) ?>
77
80
<button type="submit"
78
- title="<?= $ block ->escapeHtml (__ ('Add to Cart ' )) ?> "
81
+ title="<?= $ escaper ->escapeHtml (__ ('Add to Cart ' )) ?> "
79
82
class="action tocart primary">
80
- <span><?= $ block ->escapeHtml (__ ('Add to Cart ' )) ?> </span>
83
+ <span><?= $ escaper ->escapeHtml (__ ('Add to Cart ' )) ?> </span>
81
84
</button>
82
85
</form>
83
86
<?php if ($ block ->getBlockHtml ('formkey ' )): ?>
@@ -93,25 +96,25 @@ use Magento\Framework\App\Action\Action;
93
96
<?php endif ;?>
94
97
<?php else : ?>
95
98
<?php if ($ _item ->isAvailable ()): ?>
96
- <div class="stock available"><span><?= $ block ->escapeHtml (__ ('In stock ' )) ?> </span></div>
99
+ <div class="stock available"><span><?= $ escaper ->escapeHtml (__ ('In stock ' )) ?> </span></div>
97
100
<?php else : ?>
98
- <div class="stock unavailable"><span><?= $ block ->escapeHtml (__ ('Out of stock ' )) ?> </span></div>
101
+ <div class="stock unavailable"><span><?= $ escaper ->escapeHtml (__ ('Out of stock ' )) ?> </span></div>
99
102
<?php endif ; ?>
100
103
<?php endif ; ?>
101
104
</div>
102
105
<?php endif ; ?>
103
106
<?php if ($ showWishlist || $ showCompare ): ?>
104
107
<div class="actions-secondary" data-role="add-to-links">
105
- <?php if ($ this ->helper (\ Magento \ Wishlist \ Helper \ Data::class)->isAllow () && $ showWishlist ): ?>
108
+ <?php if ($ this ->helper (Data::class)->isAllow () && $ showWishlist ): ?>
106
109
<a href="#"
107
110
data-post='<?= /* @noEscape */ $ block ->getAddToWishlistParams ($ _item ) ?> ' class="action towishlist" data-action="add-to-wishlist" title="<?= $ block ->escapeHtmlAttr (__ ('Add to Wish List ' )) ?> ">
108
- <span><?= $ block ->escapeHtml (__ ('Add to Wish List ' )) ?> </span>
111
+ <span><?= $ escaper ->escapeHtml (__ ('Add to Wish List ' )) ?> </span>
109
112
</a>
110
113
<?php endif ; ?>
111
114
<?php if ($ block ->getAddToCompareUrl () && $ showCompare ): ?>
112
- <?php $ compareHelper = $ this ->helper (\ Magento \ Catalog \ Helper \ Product \ Compare::class);?>
115
+ <?php $ compareHelper = $ this ->helper (Compare::class);?>
113
116
<a href="#" class="action tocompare" data-post='<?= /* @noEscape */ $ compareHelper ->getPostDataParams ($ _item ) ?> ' title="<?= $ block ->escapeHtmlAttr (__ ('Add to Compare ' )) ?> ">
114
- <span><?= $ block ->escapeHtml (__ ('Add to Compare ' )) ?> </span>
117
+ <span><?= $ escaper ->escapeHtml (__ ('Add to Compare ' )) ?> </span>
115
118
</a>
116
119
<?php endif ; ?>
117
120
</div>
0 commit comments