12
12
use Magento \Framework \Registry ;
13
13
use Magento \Framework \Stdlib \DateTime \Filter \Date ;
14
14
use Magento \Framework \App \Request \DataPersistorInterface ;
15
+ use Magento \Framework \Stdlib \DateTime \TimezoneInterface ;
15
16
16
17
/**
17
18
* Save action for catalog rule
@@ -25,19 +26,27 @@ class Save extends \Magento\CatalogRule\Controller\Adminhtml\Promo\Catalog imple
25
26
*/
26
27
protected $ dataPersistor ;
27
28
29
+ /**
30
+ * @var TimezoneInterface
31
+ */
32
+ private $ localeDate ;
33
+
28
34
/**
29
35
* @param Context $context
30
36
* @param Registry $coreRegistry
31
37
* @param Date $dateFilter
32
38
* @param DataPersistorInterface $dataPersistor
39
+ * @param TimezoneInterface $localeDate
33
40
*/
34
41
public function __construct (
35
42
Context $ context ,
36
43
Registry $ coreRegistry ,
37
44
Date $ dateFilter ,
38
- DataPersistorInterface $ dataPersistor
45
+ DataPersistorInterface $ dataPersistor ,
46
+ TimezoneInterface $ localeDate
39
47
) {
40
48
$ this ->dataPersistor = $ dataPersistor ;
49
+ $ this ->localeDate = $ localeDate ;
41
50
parent ::__construct ($ context , $ coreRegistry , $ dateFilter );
42
51
}
43
52
@@ -46,16 +55,15 @@ public function __construct(
46
55
*
47
56
* @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|void
48
57
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
58
+ * @SuppressWarnings(PHPMD.NPathComplexity)
49
59
*/
50
60
public function execute ()
51
61
{
52
62
if ($ this ->getRequest ()->getPostValue ()) {
53
-
54
63
/** @var \Magento\CatalogRule\Api\CatalogRuleRepositoryInterface $ruleRepository */
55
64
$ ruleRepository = $ this ->_objectManager ->get (
56
65
\Magento \CatalogRule \Api \CatalogRuleRepositoryInterface::class
57
66
);
58
-
59
67
/** @var \Magento\CatalogRule\Model\Rule $model */
60
68
$ model = $ this ->_objectManager ->create (\Magento \CatalogRule \Model \Rule::class);
61
69
@@ -65,7 +73,9 @@ public function execute()
65
73
['request ' => $ this ->getRequest ()]
66
74
);
67
75
$ data = $ this ->getRequest ()->getPostValue ();
68
-
76
+ if (!$ this ->getRequest ()->getParam ('from_date ' )) {
77
+ $ data ['from_date ' ] = $ this ->localeDate ->formatDate ();
78
+ }
69
79
$ filterValues = ['from_date ' => $ this ->_dateFilter ];
70
80
if ($ this ->getRequest ()->getParam ('to_date ' )) {
71
81
$ filterValues ['to_date ' ] = $ this ->_dateFilter ;
0 commit comments