Skip to content

Commit 1b7697f

Browse files
refactor option save handler
1 parent 2295da4 commit 1b7697f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

app/code/Magento/Catalog/Model/Product/Option/SaveHandler.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,10 @@
1111
use Magento\Catalog\Api\Data\ProductInterface;
1212
use Magento\Catalog\Api\ProductCustomOptionRepositoryInterface as OptionRepository;
1313
use Magento\Catalog\Model\Product\Option;
14-
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
1514
use Magento\Framework\App\ObjectManager;
16-
use Magento\Catalog\Model\Product\Type;
1715
use Magento\Framework\EntityManager\Operation\ExtensionInterface;
1816
use Magento\Catalog\Model\ResourceModel\Product\Relation;
1917
use Magento\Framework\Exception\CouldNotSaveException;
20-
use Magento\GroupedProduct\Model\Product\Type\Grouped;
2118

2219
/**
2320
* SaveHandler for product option
@@ -26,6 +23,11 @@
2623
*/
2724
class SaveHandler implements ExtensionInterface
2825
{
26+
/**
27+
* @var string[]
28+
*/
29+
private $compositeProductTypes = ['grouped', 'configurable', 'bundle'];
30+
2931
/**
3032
* @var OptionRepository
3133
*/
@@ -120,9 +122,7 @@ private function processOptionsSaving(array $options, bool $hasChangedSku, Produ
120122
private function isProductHasRelations(ProductInterface $product): bool
121123
{
122124
$result = true;
123-
if ($product->getTypeId() !== Type::TYPE_BUNDLE
124-
&& $product->getTypeId() !== Configurable::TYPE_CODE
125-
&& $product->getTypeId() !== Grouped::TYPE_CODE
125+
if (!in_array($product->getId(), $this->compositeProductTypes)
126126
&& $this->relation->getRelationsByChildren([$product->getId()])
127127
) {
128128
$result = false;

0 commit comments

Comments
 (0)