-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2816 from magento-honey-badgers/MAGETWO-8709
[honey] MAGETWO-8709: [GITHUB] Child product image should be shown in Wishist if options are selected for configurable product #8168
- Loading branch information
Showing
33 changed files
with
569 additions
and
535 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
app/code/Magento/Catalog/Model/Product/Configuration/Item/ItemResolverComposite.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Catalog\Model\Product\Configuration\Item; | ||
|
||
use Magento\Catalog\Api\Data\ProductInterface; | ||
use Magento\Framework\App\ObjectManager; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
class ItemResolverComposite implements ItemResolverInterface | ||
{ | ||
/** @var string[] */ | ||
private $itemResolvers = []; | ||
|
||
/** @var ItemResolverInterface[] */ | ||
private $itemResolversInstances = []; | ||
|
||
/** | ||
* @param string[] $itemResolvers | ||
*/ | ||
public function __construct(array $itemResolvers) | ||
{ | ||
$this->itemResolvers = $itemResolvers; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getFinalProduct(ItemInterface $item) : ProductInterface | ||
{ | ||
$finalProduct = $item->getProduct(); | ||
foreach ($this->itemResolvers as $resolver) { | ||
$resolvedProduct = $this->getItemResolverInstance($resolver)->getFinalProduct($item); | ||
if ($resolvedProduct !== $finalProduct) { | ||
$finalProduct = $resolvedProduct; | ||
break; | ||
} | ||
} | ||
return $finalProduct; | ||
} | ||
|
||
/** | ||
* Get the instance of the item resolver by class name. | ||
* | ||
* @param string $className | ||
* @return ItemResolverInterface | ||
*/ | ||
private function getItemResolverInstance(string $className) : ItemResolverInterface | ||
{ | ||
if (!isset($this->itemResolversInstances[$className])) { | ||
$this->itemResolversInstances[$className] = ObjectManager::getInstance()->get($className); | ||
} | ||
return $this->itemResolversInstances[$className]; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
app/code/Magento/Catalog/Model/Product/Configuration/Item/ItemResolverInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Catalog\Model\Product\Configuration\Item; | ||
|
||
use Magento\Catalog\Api\Data\ProductInterface; | ||
|
||
/** | ||
* Resolves the product from a configured item. | ||
* | ||
* @api | ||
*/ | ||
interface ItemResolverInterface | ||
{ | ||
/** | ||
* Get the final product from a configured item by product type and selection. | ||
* | ||
* @param ItemInterface $item | ||
* @return ProductInterface | ||
*/ | ||
public function getFinalProduct(ItemInterface $item) : ProductInterface; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.