/** * {@inheritdoc} */ public function delete(\Magento\ConfigurableProduct\Api\Data\OptionInterface $option) { try { $this->optionResource->delete($option); } catch (\Exception $exception) { throw new StateException(__('Cannot delete option with id: %1', $option->getId())); } return true; }
/** * {@inheritdoc} */ public function delete(OptionInterface $option) { $product = $this->getProductById($option->getProductId()); try { $this->configurableTypeResource->saveProducts($product, []); } catch (\Exception $exception) { throw new StateException(__('Cannot delete variations from product: %1', $option->getProductId())); } try { $this->optionResource->delete($option); } catch (\Exception $exception) { throw new StateException(__('Cannot delete option with id: %1', $option->getId())); } return true; }