34 private $metadataPool;
55 $this->optionSave = $optionSave;
56 $this->metadataPool = $metadataPool
71 $bundleProductOptions =
$entity->getExtensionAttributes()->getBundleProductOptions() ?: [];
77 $existingBundleProductOptions = $this->optionRepository->getList(
$entity->getSku());
78 $existingOptionsIds = !empty($existingBundleProductOptions)
79 ? $this->getOptionIds($existingBundleProductOptions)
82 ? $this->getOptionIds($bundleProductOptions)
85 if (!
$entity->getCopyFromView()) {
87 $newOptionsIds = array_diff(
$optionIds, $existingOptionsIds);
88 $this->saveOptions(
$entity, $bundleProductOptions, $newOptionsIds);
91 $this->saveOptions(
$entity, $bundleProductOptions);
92 $entity->setCopyFromView(
false);
108 $this->productLinkManagement->removeChild($entitySku,
$option->getId(),
$link->getSku());
121 private function saveOptions(
$entity, array
$options, array $newOptionsIds = []): void
124 if (in_array(
$option->getOptionId(), $newOptionsIds,
true)) {
138 private function getOptionIds(array
$options): array
162 private function processRemovedOptions(
string $entitySku, array $existingOptionsIds, array
$optionIds): void
167 $this->optionRepository->delete(
$option);
execute($entity, $arguments=[])
__construct(OptionRepository $optionRepository, ProductLinkManagementInterface $productLinkManagement, SaveAction $optionSave, MetadataPool $metadataPool=null)
removeOptionLinks($entitySku, $option)