4
4
* See COPYING.txt for license details.
5
5
*/
6
6
7
- /**
8
- * Wishlist block customer items
9
- *
10
- * @author Magento Core Team <[email protected] >
11
- */
12
7
namespace Magento \Wishlist \Block \Share \Email ;
13
8
9
+ use Magento \Catalog \Model \Product ;
10
+ use Magento \Catalog \Model \Product \Configuration \Item \ItemResolverInterface ;
11
+ use Magento \Catalog \Model \Product \Image \UrlBuilder ;
12
+ use Magento \Framework \App \ObjectManager ;
13
+ use Magento \Framework \View \ConfigInterface ;
14
+ use Magento \Wishlist \Model \Item ;
15
+
14
16
/**
17
+ * Wishlist share items
18
+ *
15
19
* @api
16
20
* @since 100.0.2
17
21
*/
18
22
class Items extends \Magento \Wishlist \Block \AbstractBlock
19
23
{
24
+ /**
25
+ * @var ItemResolverInterface
26
+ */
27
+ private $ itemResolver ;
28
+
20
29
/**
21
30
* @var string
22
31
*/
23
32
protected $ _template = 'Magento_Wishlist::email/items.phtml ' ;
24
33
34
+ /**
35
+ * Items constructor.
36
+ *
37
+ * @param \Magento\Catalog\Block\Product\Context $context
38
+ * @param \Magento\Framework\App\Http\Context $httpContext
39
+ * @param array $data
40
+ * @param ConfigInterface|null $config
41
+ * @param UrlBuilder|null $urlBuilder
42
+ * @param ItemResolverInterface|null $itemResolver
43
+ */
44
+ public function __construct (
45
+ \Magento \Catalog \Block \Product \Context $ context ,
46
+ \Magento \Framework \App \Http \Context $ httpContext ,
47
+ array $ data = [],
48
+ ConfigInterface $ config = null ,
49
+ UrlBuilder $ urlBuilder = null ,
50
+ ItemResolverInterface $ itemResolver = null
51
+ ) {
52
+ parent ::__construct ($ context , $ httpContext , $ data , $ config , $ urlBuilder );
53
+ $ this ->itemResolver = $ itemResolver ?? ObjectManager::getInstance ()->get (ItemResolverInterface::class);
54
+ }
55
+
56
+ /**
57
+ * Identify the product from which thumbnail should be taken.
58
+ *
59
+ * @param Item $item
60
+ *
61
+ * @return Product
62
+ */
63
+ public function getProductForThumbnail (Item $ item ): Product
64
+ {
65
+ return $ this ->itemResolver ->getFinalProduct ($ item );
66
+ }
67
+
25
68
/**
26
69
* Retrieve Product View URL
27
70
*
28
71
* @param \Magento\Catalog\Model\Product $product
29
72
* @param array $additional
73
+ *
30
74
* @return string
31
75
*/
32
76
public function getProductUrl ($ product , $ additional = [])
@@ -40,6 +84,7 @@ public function getProductUrl($product, $additional = [])
40
84
*
41
85
* @param \Magento\Catalog\Model\Product $product
42
86
* @param array $additional
87
+ *
43
88
* @return string
44
89
*/
45
90
public function getAddToCartUrl ($ product , $ additional = [])
@@ -53,6 +98,7 @@ public function getAddToCartUrl($product, $additional = [])
53
98
* Check whether wishlist item has description
54
99
*
55
100
* @param \Magento\Wishlist\Model\Item $item
101
+ *
56
102
* @return bool
57
103
*/
58
104
public function hasDescription ($ item )
0 commit comments