Skip to content

Commit

Permalink
MAGETWO-8709: [GITHUB] Child product image should be shown in Wishist…
Browse files Browse the repository at this point in the history
… if options are selected for configurable product #8168

- adding optimization
  • Loading branch information
cpartica committed Jul 18, 2018
1 parent c1a3261 commit dc056bf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,19 @@ public function getFinalProduct(ItemInterface $item) : ProductInterface
* or if child thumbnail is not available.
*/
$parentProduct = $item->getProduct();
$configValue = $this->scopeConfig->getValue(
self::CONFIG_THUMBNAIL_SOURCE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);

$finalProduct = $parentProduct;
$childProduct = $this->getChildProduct($item);
$childThumb = $childProduct->getData('thumbnail');
$finalProduct =
($configValue == Thumbnail::OPTION_USE_PARENT_IMAGE) || (!$childThumb || $childThumb == 'no_selection')
? $parentProduct
: $childProduct;
if ($childProduct !== $parentProduct) {
$configValue = $this->scopeConfig->getValue(
self::CONFIG_THUMBNAIL_SOURCE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
$childThumb = $childProduct->getData('thumbnail');
$finalProduct =
($configValue == Thumbnail::OPTION_USE_PARENT_IMAGE) || (!$childThumb || $childThumb == 'no_selection')
? $parentProduct
: $childProduct;
}
return $finalProduct;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,22 @@ public function getFinalProduct(ItemInterface $item) : ProductInterface
* Show grouped product thumbnail if it must be always shown according to the related setting in system config
* or if child product thumbnail is not available.
*/
$configValue = $this->scopeConfig->getValue(
self::CONFIG_THUMBNAIL_SOURCE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);

$childProduct = $item->getProduct();
$childThumb = $childProduct->getData('thumbnail');
$finalProduct = $childProduct;
$parentProduct = $this->getParentProduct($item);
if ($childProduct !== $parentProduct) {
$configValue = $this->scopeConfig->getValue(
self::CONFIG_THUMBNAIL_SOURCE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
$childThumb = $childProduct->getData('thumbnail');

$finalProduct =
($configValue == Thumbnail::OPTION_USE_PARENT_IMAGE) || (!$childThumb || $childThumb == 'no_selection')
? $this->getParentProduct($item)
: $childProduct;
$finalProduct =
($configValue == Thumbnail::OPTION_USE_PARENT_IMAGE) || (!$childThumb || $childThumb == 'no_selection')
? $parentProduct
: $childProduct;
}
return $finalProduct;
}

Expand Down

0 comments on commit dc056bf

Please sign in to comment.