Skip to content

Commit

Permalink
ENGCOM-7062: #27124: Update wishlist image logic to match logic on wi…
Browse files Browse the repository at this point in the history
…shlist page #27125
  • Loading branch information
slavvka authored Mar 18, 2020
2 parents 9b5e747 + 3f4f646 commit c3b42db
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 16 deletions.
56 changes: 51 additions & 5 deletions app/code/Magento/Wishlist/Block/Share/Email/Items.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,73 @@
* See COPYING.txt for license details.
*/

/**
* Wishlist block customer items
*
* @author Magento Core Team <[email protected]>
*/
namespace Magento\Wishlist\Block\Share\Email;

use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Configuration\Item\ItemResolverInterface;
use Magento\Catalog\Model\Product\Image\UrlBuilder;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\View\ConfigInterface;
use Magento\Wishlist\Model\Item;

/**
* Wishlist share items
*
* @api
* @since 100.0.2
*/
class Items extends \Magento\Wishlist\Block\AbstractBlock
{
/**
* @var ItemResolverInterface
*/
private $itemResolver;

/**
* @var string
*/
protected $_template = 'Magento_Wishlist::email/items.phtml';

/**
* Items constructor.
*
* @param \Magento\Catalog\Block\Product\Context $context
* @param \Magento\Framework\App\Http\Context $httpContext
* @param array $data
* @param ConfigInterface|null $config
* @param UrlBuilder|null $urlBuilder
* @param ItemResolverInterface|null $itemResolver
*/
public function __construct(
\Magento\Catalog\Block\Product\Context $context,
\Magento\Framework\App\Http\Context $httpContext,
array $data = [],
ConfigInterface $config = null,
UrlBuilder $urlBuilder = null,
ItemResolverInterface $itemResolver = null
) {
parent::__construct($context, $httpContext, $data, $config, $urlBuilder);
$this->itemResolver = $itemResolver ?? ObjectManager::getInstance()->get(ItemResolverInterface::class);
}

/**
* Identify the product from which thumbnail should be taken.
*
* @param Item $item
*
* @return Product
*/
public function getProductForThumbnail(Item $item): Product
{
return $this->itemResolver->getFinalProduct($item);
}

/**
* Retrieve Product View URL
*
* @param \Magento\Catalog\Model\Product $product
* @param array $additional
*
* @return string
*/
public function getProductUrl($product, $additional = [])
Expand All @@ -40,6 +84,7 @@ public function getProductUrl($product, $additional = [])
*
* @param \Magento\Catalog\Model\Product $product
* @param array $additional
*
* @return string
*/
public function getAddToCartUrl($product, $additional = [])
Expand All @@ -53,6 +98,7 @@ public function getAddToCartUrl($product, $additional = [])
* Check whether wishlist item has description
*
* @param \Magento\Wishlist\Model\Item $item
*
* @return bool
*/
public function hasDescription($item)
Expand Down
23 changes: 12 additions & 11 deletions app/code/Magento/Wishlist/view/frontend/templates/email/items.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,43 @@
<table>
<tr>
<?php $i = 0;
foreach ($block->getWishlistItems() as $item) : $i++ ?>
<?php /* @var $item \Magento\Wishlist\Model\Item */ ?>
<?php /* @var $_product \Magento\Catalog\Model\Product */ ?>
foreach ($block->getWishlistItems() as $item): $i++ ?>
<?php /* @var \Magento\Wishlist\Model\Item $item */ ?>
<?php /* @var \Magento\Catalog\Model\Product $_product */ ?>
<?php $_product = $item->getProduct(); ?>
<td class="col product">
<p>
<a href="<?= $block->escapeUrl($block->getProductUrl($_product)) ?>">
<?= /* @noEscape */ $block->getImage($_product, 'product_small_image')->toHtml() ?>
<a href="<?= $block->escapeUrl($block->getProductUrl($item)) ?>">
<?php $productThumbnail = $block->getProductForThumbnail($item) ?>
<?= /* @noEscape */ $block->getImage($productThumbnail, 'product_small_image')->toHtml() ?>
</a>
</p>

<p>
<a href="<?= $block->escapeUrl($block->getProductUrl($_product)) ?>">
<a href="<?= $block->escapeUrl($block->getProductUrl($item)) ?>">
<strong><?= $block->escapeHtml($_product->getName()) ?></strong>
</a>
</p>
<?php if ($block->hasDescription($item)) : ?>
<?php if ($block->hasDescription($item)): ?>
<p>
<strong><?= $block->escapeHtml(__('Comment')) ?>:</strong>
<br/><?= /* @noEscape */ $block->getEscapedDescription($item) ?>
</p>
<?php endif; ?>
<p>
<a href="<?= $block->escapeUrl($block->getProductUrl($_product)) ?>">
<a href="<?= $block->escapeUrl($block->getProductUrl($item)) ?>">
<?= $block->escapeHtml(__('View Product')) ?>
</a>
</p>
</td>
<?php if ($i % 3 != 0) : ?>
<?php if ($i % 3 != 0): ?>
<td></td>
<?php else : ?>
<?php else: ?>
</tr>
<tr>
<td colspan="5">&nbsp;</td>
</tr>
<?php if ($i < $l) : ?>
<?php if ($i < $l): ?>
<tr>
<?php endif ?>
<?php endif ?>
Expand Down

0 comments on commit c3b42db

Please sign in to comment.