Skip to content

Commit

Permalink
Merge branch 'pr-35299' into 2.4-develop-prs
Browse files Browse the repository at this point in the history
  • Loading branch information
ishakhsuvarov committed Jun 7, 2022
2 parents ff750b9 + 7465e26 commit f02d61e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/code/Magento/Catalog/Model/Product/Option/SaveHandler.php
Expand Up @@ -11,9 +11,9 @@
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Api\ProductCustomOptionRepositoryInterface as OptionRepository;
use Magento\Catalog\Model\Product\Option;
use Magento\Catalog\Model\ResourceModel\Product\Relation;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\EntityManager\Operation\ExtensionInterface;
use Magento\Catalog\Model\ResourceModel\Product\Relation;
use Magento\Framework\Exception\CouldNotSaveException;

/**
Expand All @@ -26,12 +26,12 @@ class SaveHandler implements ExtensionInterface
/**
* @var string[]
*/
private $compositeProductTypes = ['grouped', 'configurable', 'bundle'];
private array $compositeProductTypes = ['grouped', 'configurable', 'bundle'];

/**
* @var OptionRepository
*/
protected $optionRepository;
protected OptionRepository $optionRepository;

/**
* @var Relation
Expand All @@ -44,7 +44,7 @@ class SaveHandler implements ExtensionInterface
*/
public function __construct(
OptionRepository $optionRepository,
?Relation $relation = null
?Relation $relation = null
) {
$this->optionRepository = $optionRepository;
$this->relation = $relation ?: ObjectManager::getInstance()->get(Relation::class);
Expand All @@ -57,6 +57,7 @@ public function __construct(
* @param array $arguments
* @return ProductInterface|object
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @throws CouldNotSaveException
*/
public function execute($entity, $arguments = [])
{
Expand Down Expand Up @@ -122,12 +123,11 @@ private function processOptionsSaving(array $options, bool $hasChangedSku, Produ
private function isProductHasRelations(ProductInterface $product): bool
{
$result = true;
if (!in_array($product->getId(), $this->compositeProductTypes)
if (!in_array($product->getTypeId(), $this->compositeProductTypes)
&& $this->relation->getRelationsByChildren([$product->getId()])
) {
$result = false;
}

return $result;
}
}

0 comments on commit f02d61e

Please sign in to comment.