Skip to content

Commit c2c8ef9

Browse files
committed
MAGETWO-8709: [GITHUB] Child product image should be shown in Wishist if options are selected for configurable product #8168
- fixing formatting
1 parent 31f089f commit c2c8ef9

File tree

5 files changed

+24
-18
lines changed

5 files changed

+24
-18
lines changed

app/code/Magento/Catalog/Model/Product/Configuration/Item/ItemResolverComposite.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ class ItemResolverComposite implements ItemResolverInterface
1818
/** @var string[] */
1919
private $itemResolvers = [];
2020

21+
/** @var ItemResolverInterface[] */
22+
private $itemResolversInstances = [];
23+
2124
/**
2225
* @param string[] $itemResolvers
2326
*/
@@ -43,13 +46,16 @@ public function getFinalProduct(ItemInterface $item) : ProductInterface
4346
}
4447

4548
/**
46-
* Get the instance of the item resolver by class name
49+
* Get the instance of the item resolver by class name.
4750
*
4851
* @param string $className
4952
* @return ItemResolverInterface
5053
*/
5154
private function getItemResolverInstance(string $className)
5255
{
53-
return ObjectManager::getInstance()->get($className);
56+
if (!isset($this->itemResolversInstances[$className])) {
57+
$this->itemResolversInstances[$className] = ObjectManager::getInstance()->get($className);
58+
}
59+
return $this->itemResolversInstances[$className];
5460
}
5561
}

app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/RendererTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected function setUp()
4747
->getMock();
4848
$context->expects($this->once())
4949
->method('getLayout')
50-
->will($this->returnValue($this->layout));
50+
->willReturn($this->layout);
5151

5252
$this->imageBuilder = $this->getMockBuilder(\Magento\Catalog\Block\Product\ImageBuilder::class)
5353
->disableOriginalConstructor()

app/code/Magento/ConfigurableProduct/Model/Product/Configuration/Item/ItemProductResolver.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,23 @@ public function getFinalProduct(ItemInterface $item) : ProductInterface
4646
* Show parent product thumbnail if it must be always shown according to the related setting in system config
4747
* or if child thumbnail is not available.
4848
*/
49-
$parentItem = $item->getProduct();
50-
$config = $this->scopeConfig->getValue(
49+
$parentProduct = $item->getProduct();
50+
$configValue = $this->scopeConfig->getValue(
5151
self::CONFIG_THUMBNAIL_SOURCE,
5252
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
5353
);
5454

5555
$childProduct = $this->getChildProduct($item);
56-
$childThumbnail = $childProduct->getData('thumbnail');
56+
$childThumb = $childProduct->getData('thumbnail');
5757
$finalProduct =
58-
($config == Thumbnail::OPTION_USE_PARENT_IMAGE) || (!$childThumbnail || $childThumbnail == 'no_selection')
59-
? $parentItem
58+
($configValue == Thumbnail::OPTION_USE_PARENT_IMAGE) || (!$childThumb || $childThumb == 'no_selection')
59+
? $parentProduct
6060
: $childProduct;
6161
return $finalProduct;
6262
}
6363

6464
/**
65-
* Get item configurable child product
65+
* Get item configurable child product.
6666
*
6767
* @param ItemInterface $item
6868
* @return Product

app/code/Magento/GroupedProduct/Model/Product/Configuration/Item/ItemProductResolver.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,24 @@ public function getFinalProduct(ItemInterface $item) : ProductInterface
4444
{
4545
/**
4646
* Show grouped product thumbnail if it must be always shown according to the related setting in system config
47-
* or if child product thumbnail is not available
47+
* or if child product thumbnail is not available.
4848
*/
49-
$config = $this->scopeConfig->getValue(
49+
$configValue = $this->scopeConfig->getValue(
5050
self::CONFIG_THUMBNAIL_SOURCE,
5151
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
5252
);
5353
$childProduct = $item->getProduct();
54-
$childThumbnail = $childProduct->getData('thumbnail');
54+
$childThumb = $childProduct->getData('thumbnail');
5555

5656
$finalProduct =
57-
($config == Thumbnail::OPTION_USE_PARENT_IMAGE) || (!$childThumbnail || $childThumbnail == 'no_selection')
57+
($configValue == Thumbnail::OPTION_USE_PARENT_IMAGE) || (!$childThumb || $childThumb == 'no_selection')
5858
? $this->getParentProduct($item)
5959
: $childProduct;
6060
return $finalProduct;
6161
}
6262

6363
/**
64-
* Get grouped product
64+
* Get grouped product.
6565
*
6666
* @param ItemInterface $item
6767
* @return Product

app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Column/Image.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

7-
/**
8-
* Wishlist block customer item cart column
9-
*/
108
namespace Magento\Wishlist\Block\Customer\Wishlist\Item\Column;
119

1210
use Magento\Catalog\Model\Product\Image\UrlBuilder;
@@ -15,6 +13,8 @@
1513
use Magento\Catalog\Model\Product\Configuration\Item\ItemResolverInterface;
1614

1715
/**
16+
* Wishlist block customer item cart column
17+
*
1818
* @api
1919
* @since 100.0.2
2020
*/
@@ -54,7 +54,7 @@ public function __construct(
5454
*
5555
* @return \Magento\Catalog\Model\Product
5656
*/
57-
public function getProductForThumbnail(\Magento\Wishlist\Model\Item $item)
57+
public function getProductForThumbnail(\Magento\Wishlist\Model\Item $item) : \Magento\Catalog\Model\Product
5858
{
5959
return $this->itemResolver->getFinalProduct($item);
6060
}

0 commit comments

Comments
 (0)