Skip to content

Commit 31f089f

Browse files
committed
MAGETWO-8709: [GITHUB] Child product image should be shown in Wishist if options are selected for configurable product #8168
- removing object from composite - removing un-necessary methods
1 parent f68e7d1 commit 31f089f

File tree

5 files changed

+17
-25
lines changed

5 files changed

+17
-25
lines changed

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@
88
namespace Magento\Catalog\Model\Product\Configuration\Item;
99

1010
use Magento\Catalog\Api\Data\ProductInterface;
11+
use Magento\Framework\App\ObjectManager;
1112

1213
/**
1314
* {@inheritdoc}
1415
*/
1516
class ItemResolverComposite implements ItemResolverInterface
1617
{
17-
/** @var ItemResolverInterface[] */
18+
/** @var string[] */
1819
private $itemResolvers = [];
1920

2021
/**
21-
* @param ItemResolverInterface[] $itemResolvers
22+
* @param string[] $itemResolvers
2223
*/
2324
public function __construct(array $itemResolvers)
2425
{
@@ -32,12 +33,23 @@ public function getFinalProduct(ItemInterface $item) : ProductInterface
3233
{
3334
$product = $item->getProduct();
3435
foreach ($this->itemResolvers as $resolver) {
35-
$resolvedProduct = $resolver->getFinalProduct($item);
36+
$resolvedProduct = $this->getItemResolverInstance($resolver)->getFinalProduct($item);
3637
if ($resolvedProduct !== $product) {
3738
$product = $resolvedProduct;
3839
break;
3940
}
4041
}
4142
return $product;
4243
}
44+
45+
/**
46+
* Get the instance of the item resolver by class name
47+
*
48+
* @param string $className
49+
* @return ItemResolverInterface
50+
*/
51+
private function getItemResolverInstance(string $className)
52+
{
53+
return ObjectManager::getInstance()->get($className);
54+
}
4355
}

app/code/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/Configurable.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,6 @@ public function getOptionList()
5757
return $this->_productConfig->getOptions($this->getItem());
5858
}
5959

60-
/**
61-
* {@inheritdoc}
62-
* @deprecated because now parent handles the logic for images of all product types
63-
* @see \Magento\Checkout\Block\Cart\Item\Renderer::getProductForThumbnail
64-
*/
65-
public function getProductForThumbnail()
66-
{
67-
return parent::getProductForThumbnail();
68-
}
69-
7060
/**
7161
* Return identifiers for produced content
7262
*

app/code/Magento/ConfigurableProduct/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@
208208
<type name="Magento\Catalog\Model\Product\Configuration\Item\ItemResolverComposite">
209209
<arguments>
210210
<argument name="itemResolvers" xsi:type="array">
211-
<item name="configurable" xsi:type="object">Magento\ConfigurableProduct\Model\Product\Configuration\Item\ItemProductResolver</item>
211+
<item name="configurable" xsi:type="string">Magento\ConfigurableProduct\Model\Product\Configuration\Item\ItemProductResolver</item>
212212
</argument>
213213
</arguments>
214214
</type>

app/code/Magento/GroupedProduct/Block/Cart/Item/Renderer/Grouped.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,6 @@ public function getGroupedProduct()
3838
return $this->getProduct();
3939
}
4040

41-
/**
42-
* {@inheritdoc}
43-
* @deprecated because now parent handles the logic for images of all product types
44-
* @see \Magento\Checkout\Block\Cart\Item\Renderer::getProductForThumbnail
45-
*/
46-
public function getProductForThumbnail()
47-
{
48-
return parent::getProductForThumbnail();
49-
}
50-
5141
/**
5242
* Return identifiers for produced content
5343
*

app/code/Magento/GroupedProduct/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
<type name="Magento\Catalog\Model\Product\Configuration\Item\ItemResolverComposite">
104104
<arguments>
105105
<argument name="itemResolvers" xsi:type="array">
106-
<item name="grouped" xsi:type="object">Magento\GroupedProduct\Model\Product\Configuration\Item\ItemProductResolver</item>
106+
<item name="grouped" xsi:type="string">Magento\GroupedProduct\Model\Product\Configuration\Item\ItemProductResolver</item>
107107
</argument>
108108
</arguments>
109109
</type>

0 commit comments

Comments
 (0)