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