_coreRegistry = $coreRegistry; $this->_fileFactory = $fileFactory; $this->_dateFilter = $dateFilter; $this->resultPageFactory = $resultPageFactory; } /** * Promo quote edit action * * @return void * @SuppressWarnings(PHPMD.NPathComplexity) */ public function execute() { $id = $this->getRequest()->getParam('id'); $model = $this->_objectManager->create(\Magento\SalesRule\Model\Rule::class); $this->_coreRegistry->register(\Magento\SalesRule\Model\RegistryConstants::CURRENT_SALES_RULE, $model); $resultPage = $this->resultPageFactory->create(); if ($id) { $model->load($id); if (!$model->getRuleId()) { $this->messageManager->addErrorMessage(__('This rule no longer exists.')); $this->_redirect('sales_rule/*'); return; } $model->getConditions()->setFormName('sales_rule_form'); $model->getConditions()->setJsFormObject( $model->getConditionsFieldSetId($model->getConditions()->getFormName()) ); $model->getActions()->setFormName('sales_rule_form'); $model->getActions()->setJsFormObject( $model->getActionsFieldSetId($model->getActions()->getFormName()) ); $resultPage->getLayout()->getBlock('promo_sales_rule_edit_tab_coupons')->setCanShow(true); } // set entered data if was error when we do save $data = $this->_objectManager->get(\Magento\Backend\Model\Session::class)->getPageData(true); if (!empty($data)) { $model->addData($data); } $this->_initAction(); $this->_addBreadcrumb($id ? __('Edit Rule') : __('New Rule'), $id ? __('Edit Rule') : __('New Rule')); $this->_view->getPage()->getConfig()->getTitle()->prepend( $model->getRuleId() ? $model->getName() : __('New Cart Price Rule') ); $this->_view->renderLayout(); } }