-
Notifications
You must be signed in to change notification settings - Fork 9.3k
/
Edit.php
52 lines (44 loc) · 1.7 KB
/
Edit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
*
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\SalesRule\Controller\Adminhtml\Promo\Quote;
class Edit extends \Magento\SalesRule\Controller\Adminhtml\Promo\Quote
{
/**
* 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');
if ($id) {
$model->load($id);
if (!$model->getRuleId()) {
$this->messageManager->addError(__('This rule no longer exists.'));
$this->_redirect('sales_rule/*');
return;
}
}
// set entered data if was error when we do save
$data = $this->_objectManager->get('Magento\Backend\Model\Session')->getPageData(true);
if (!empty($data)) {
$model->addData($data);
}
$model->getConditions()->setJsFormObject('rule_conditions_fieldset');
$model->getActions()->setJsFormObject('rule_actions_fieldset');
$this->_coreRegistry->register('current_promo_quote_rule', $model);
$this->_initAction();
$this->_view->getLayout()->getBlock('promo_quote_edit')->setData('action', $this->getUrl('sales_rule/*/save'));
$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();
}
}