/** * {@inheritdoc} */ public function save(\Magento\Eav\Api\Data\AttributeInterface $attribute) { try { $this->eavResource->save($attribute); } catch (\Exception $e) { throw new StateException(__('Cannot save attribute')); } return $attribute; }
/** * {@inheritdoc} */ public function delete($entityType, $attributeCode, $optionId) { if (empty($attributeCode)) { throw new InputException(__('Empty attribute code')); } $attribute = $this->attributeRepository->get($entityType, $attributeCode); if (!$attribute->usesSource()) { throw new StateException(__('Attribute %1 doesn\'t have any option', $attributeCode)); } $this->validateOption($attribute, $optionId); $removalMarker = ['option' => ['value' => [$optionId => []], 'delete' => [$optionId => '1']]]; $attribute->addData($removalMarker); try { $this->resourceModel->save($attribute); } catch (\Exception $e) { throw new StateException(__('Cannot save attribute %1', $attributeCode)); } return true; }
/** * {@inheritdoc} */ public function save(\Magento\Framework\Model\AbstractModel $object) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'save'); if (!$pluginInfo) { return parent::save($object); } else { return $this->___callPlugins('save', func_get_args(), $pluginInfo); } }