Skip to content

Commit 854761d

Browse files
author
Michael Bottens
committed
#27124: Update wishlist image logic to match logic on wishlist page
1 parent 6bcc25b commit 854761d

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

app/code/Magento/Wishlist/Block/Share/Email/Items.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,57 @@
1111
*/
1212
namespace Magento\Wishlist\Block\Share\Email;
1313

14+
use Magento\Catalog\Model\Product;
15+
use Magento\Catalog\Model\Product\Configuration\Item\ItemResolverInterface;
16+
use Magento\Catalog\Model\Product\Image\UrlBuilder;
17+
use Magento\Framework\View\ConfigInterface;
18+
use Magento\Wishlist\Model\Item;
19+
1420
/**
1521
* @api
1622
* @since 100.0.2
1723
*/
1824
class Items extends \Magento\Wishlist\Block\AbstractBlock
1925
{
26+
/** @var ItemResolverInterface */
27+
private $itemResolver;
28+
2029
/**
2130
* @var string
2231
*/
2332
protected $_template = 'Magento_Wishlist::email/items.phtml';
2433

34+
/**
35+
* @param \Magento\Catalog\Block\Product\Context $context
36+
* @param \Magento\Framework\App\Http\Context $httpContext
37+
* @param ItemResolverInterface $itemResolver
38+
* @param array $data
39+
* @param ConfigInterface|null $config
40+
* @param UrlBuilder|null $urlBuilder
41+
*/
42+
public function __construct(
43+
\Magento\Catalog\Block\Product\Context $context,
44+
\Magento\Framework\App\Http\Context $httpContext,
45+
ItemResolverInterface $itemResolver,
46+
array $data = [],
47+
ConfigInterface $config = null,
48+
UrlBuilder $urlBuilder = null
49+
) {
50+
$this->itemResolver = $itemResolver;
51+
parent::__construct($context, $httpContext, $data, $config, $urlBuilder);
52+
}
53+
54+
/**
55+
* Identify the product from which thumbnail should be taken.
56+
*
57+
* @param Item $item
58+
* @return Product
59+
*/
60+
public function getProductForThumbnail(Item $item) : Product
61+
{
62+
return $this->itemResolver->getFinalProduct($item);
63+
}
64+
2565
/**
2666
* Retrieve Product View URL
2767
*

app/code/Magento/Wishlist/view/frontend/templates/email/items.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<td class="col product">
1919
<p>
2020
<a href="<?= $block->escapeUrl($block->getProductUrl($_product)) ?>">
21-
<?= /* @noEscape */ $block->getImage($_product, 'product_small_image')->toHtml() ?>
21+
<?= /* @noEscape */ $block->getImage($block->getProductForThumbnail($item), 'product_small_image')->toHtml() ?>
2222
</a>
2323
</p>
2424

0 commit comments

Comments
 (0)