From 854761db86de5a2bb960fc66c0b9922dd792f423 Mon Sep 17 00:00:00 2001 From: Michael Bottens Date: Mon, 2 Mar 2020 11:45:45 -0500 Subject: [PATCH 1/5] #27124: Update wishlist image logic to match logic on wishlist page --- .../Wishlist/Block/Share/Email/Items.php | 40 +++++++++++++++++++ .../view/frontend/templates/email/items.phtml | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Wishlist/Block/Share/Email/Items.php b/app/code/Magento/Wishlist/Block/Share/Email/Items.php index d4e6587fd6519..0887951d180aa 100644 --- a/app/code/Magento/Wishlist/Block/Share/Email/Items.php +++ b/app/code/Magento/Wishlist/Block/Share/Email/Items.php @@ -11,17 +11,57 @@ */ 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\View\ConfigInterface; +use Magento\Wishlist\Model\Item; + /** * @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'; + /** + * @param \Magento\Catalog\Block\Product\Context $context + * @param \Magento\Framework\App\Http\Context $httpContext + * @param ItemResolverInterface $itemResolver + * @param array $data + * @param ConfigInterface|null $config + * @param UrlBuilder|null $urlBuilder + */ + public function __construct( + \Magento\Catalog\Block\Product\Context $context, + \Magento\Framework\App\Http\Context $httpContext, + ItemResolverInterface $itemResolver, + array $data = [], + ConfigInterface $config = null, + UrlBuilder $urlBuilder = null + ) { + $this->itemResolver = $itemResolver; + parent::__construct($context, $httpContext, $data, $config, $urlBuilder); + } + + /** + * 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 * diff --git a/app/code/Magento/Wishlist/view/frontend/templates/email/items.phtml b/app/code/Magento/Wishlist/view/frontend/templates/email/items.phtml index 449d4c43c5aa0..a7cfabc7da35f 100644 --- a/app/code/Magento/Wishlist/view/frontend/templates/email/items.phtml +++ b/app/code/Magento/Wishlist/view/frontend/templates/email/items.phtml @@ -18,7 +18,7 @@

- getImage($_product, 'product_small_image')->toHtml() ?> + getImage($block->getProductForThumbnail($item), 'product_small_image')->toHtml() ?>

From 12ae6e594d260f39f316cf65d4de66516dbdb200 Mon Sep 17 00:00:00 2001 From: Michael Bottens Date: Tue, 3 Mar 2020 08:06:48 -0500 Subject: [PATCH 2/5] Update wishlist email product link to match wishlist page --- .../Wishlist/view/frontend/templates/email/items.phtml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Wishlist/view/frontend/templates/email/items.phtml b/app/code/Magento/Wishlist/view/frontend/templates/email/items.phtml index a7cfabc7da35f..8c71a8de033dc 100644 --- a/app/code/Magento/Wishlist/view/frontend/templates/email/items.phtml +++ b/app/code/Magento/Wishlist/view/frontend/templates/email/items.phtml @@ -17,13 +17,13 @@ getProduct(); ?>

- + getImage($block->getProductForThumbnail($item), 'product_small_image')->toHtml() ?>

- + escapeHtml($_product->getName()) ?>

@@ -34,7 +34,7 @@

- + escapeHtml(__('View Product')) ?>

From 76e61aecca249855bf9f45c25672bd800121e58e Mon Sep 17 00:00:00 2001 From: Michael Bottens Date: Wed, 4 Mar 2020 07:57:47 -0500 Subject: [PATCH 3/5] CR fixes --- .../Magento/Wishlist/Block/Share/Email/Items.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/Wishlist/Block/Share/Email/Items.php b/app/code/Magento/Wishlist/Block/Share/Email/Items.php index 0887951d180aa..c7ff49943b222 100644 --- a/app/code/Magento/Wishlist/Block/Share/Email/Items.php +++ b/app/code/Magento/Wishlist/Block/Share/Email/Items.php @@ -14,6 +14,7 @@ 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; @@ -23,7 +24,9 @@ */ class Items extends \Magento\Wishlist\Block\AbstractBlock { - /** @var ItemResolverInterface */ + /** + * @var ItemResolverInterface + */ private $itemResolver; /** @@ -32,23 +35,24 @@ class Items extends \Magento\Wishlist\Block\AbstractBlock protected $_template = 'Magento_Wishlist::email/items.phtml'; /** + * Items constructor. * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Framework\App\Http\Context $httpContext - * @param ItemResolverInterface $itemResolver * @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, - ItemResolverInterface $itemResolver, array $data = [], ConfigInterface $config = null, - UrlBuilder $urlBuilder = null + UrlBuilder $urlBuilder = null, + ItemResolverInterface $itemResolver = null ) { - $this->itemResolver = $itemResolver; parent::__construct($context, $httpContext, $data, $config, $urlBuilder); + $this->itemResolver = $itemResolver ?? ObjectManager::getInstance()->get(ItemResolverInterface::class); } /** @@ -57,7 +61,7 @@ public function __construct( * @param Item $item * @return Product */ - public function getProductForThumbnail(Item $item) : Product + public function getProductForThumbnail(Item $item): Product { return $this->itemResolver->getFinalProduct($item); } From 428605d04e815c782cfbe20922f244970d153006 Mon Sep 17 00:00:00 2001 From: Eduard Chitoraga Date: Fri, 6 Mar 2020 22:29:04 +0200 Subject: [PATCH 4/5] Static tests fixes --- .../Magento/Wishlist/Block/Share/Email/Items.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Wishlist/Block/Share/Email/Items.php b/app/code/Magento/Wishlist/Block/Share/Email/Items.php index c7ff49943b222..130c7cb136afb 100644 --- a/app/code/Magento/Wishlist/Block/Share/Email/Items.php +++ b/app/code/Magento/Wishlist/Block/Share/Email/Items.php @@ -4,11 +4,6 @@ * See COPYING.txt for license details. */ -/** - * Wishlist block customer items - * - * @author Magento Core Team - */ namespace Magento\Wishlist\Block\Share\Email; use Magento\Catalog\Model\Product; @@ -19,6 +14,8 @@ use Magento\Wishlist\Model\Item; /** + * Wishlist share items + * * @api * @since 100.0.2 */ @@ -36,6 +33,7 @@ class Items extends \Magento\Wishlist\Block\AbstractBlock /** * Items constructor. + * * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Framework\App\Http\Context $httpContext * @param array $data @@ -59,6 +57,7 @@ public function __construct( * Identify the product from which thumbnail should be taken. * * @param Item $item + * * @return Product */ public function getProductForThumbnail(Item $item): Product @@ -71,6 +70,7 @@ public function getProductForThumbnail(Item $item): Product * * @param \Magento\Catalog\Model\Product $product * @param array $additional + * * @return string */ public function getProductUrl($product, $additional = []) @@ -84,6 +84,7 @@ public function getProductUrl($product, $additional = []) * * @param \Magento\Catalog\Model\Product $product * @param array $additional + * * @return string */ public function getAddToCartUrl($product, $additional = []) @@ -97,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) From b2d07939fa03becf51151ebc49597614a71d3397 Mon Sep 17 00:00:00 2001 From: Eduard Chitoraga Date: Fri, 6 Mar 2020 22:32:03 +0200 Subject: [PATCH 5/5] Static tests fixes --- .../view/frontend/templates/email/items.phtml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Wishlist/view/frontend/templates/email/items.phtml b/app/code/Magento/Wishlist/view/frontend/templates/email/items.phtml index 8c71a8de033dc..782b7d4892e62 100644 --- a/app/code/Magento/Wishlist/view/frontend/templates/email/items.phtml +++ b/app/code/Magento/Wishlist/view/frontend/templates/email/items.phtml @@ -11,14 +11,15 @@ getWishlistItems() as $item) : $i++ ?> - - + foreach ($block->getWishlistItems() as $item): $i++ ?> + + getProduct(); ?> - + - + - +

- getImage($block->getProductForThumbnail($item), 'product_small_image')->toHtml() ?> + getProductForThumbnail($item) ?> + getImage($productThumbnail, 'product_small_image')->toHtml() ?>

@@ -27,7 +28,7 @@ escapeHtml($_product->getName()) ?>

- hasDescription($item)) : ?> + hasDescription($item)): ?>

escapeHtml(__('Comment')) ?>:
getEscapedDescription($item) ?> @@ -39,14 +40,14 @@