/** * @return \Magento\Backend\Model\View\Result\Redirect */ public function execute() { $setId = $this->getRequest()->getParam('id'); $resultRedirect = $this->resultRedirectFactory->create(); try { $this->attributeSetRepository->deleteById($setId); $this->messageManager->addSuccess(__('The attribute set has been removed.')); $resultRedirect->setPath('catalog/*/'); } catch (\Exception $e) { $this->messageManager->addError(__('We can\'t delete this set right now.')); $resultRedirect->setUrl($this->_redirect->getRedirectUrl($this->getUrl('*'))); } return $resultRedirect; }
/** * {@inheritdoc} */ public function deleteById($attributeSetId) { $this->get($attributeSetId); return $this->attributeSetRepository->deleteById($attributeSetId); }