@@ -83,9 +83,9 @@ public function execute()
83
83
/** @var \Magento\Cms\Model\Page $page */
84
84
$ page = $ this ->pageRepository ->getById ($ pageId );
85
85
try {
86
- $ pageData = $ this ->filterPost ($ postItems [$ pageId ]);
87
- $ this ->validatePost ($ pageData , $ page , $ error , $ messages );
88
86
$ extendedPageData = $ page ->getData ();
87
+ $ pageData = $ this ->filterPostWithoutDate ($ postItems [$ pageId ], $ extendedPageData );
88
+ $ this ->validatePost ($ pageData , $ page , $ error , $ messages );
89
89
$ this ->setCmsPageData ($ page , $ extendedPageData , $ pageData );
90
90
$ this ->pageRepository ->save ($ page );
91
91
} catch (\Magento \Framework \Exception \LocalizedException $ e ) {
@@ -127,6 +127,32 @@ protected function filterPost($postData = [])
127
127
return $ pageData ;
128
128
}
129
129
130
+ /**
131
+ * Filtering posted data without changing custom theme dates
132
+ *
133
+ * @param array $postData
134
+ * @param array $pageData
135
+ * @return array
136
+ */
137
+ private function filterPostWithoutDate ($ postData = [], $ pageData = [])
138
+ {
139
+ $ newPageData = $ this ->filterPost ($ postData );
140
+ if (
141
+ !empty ($ newPageData ['custom_theme_from ' ]) &&
142
+ date ("Y-m-d " , strtotime ($ postData ['custom_theme_from ' ])) ===
143
+ date ("Y-m-d " , strtotime ($ pageData ['custom_theme_from ' ]))
144
+ ) {
145
+ $ newPageData ['custom_theme_from ' ] = date ("Y-m-d " , strtotime ($ postData ['custom_theme_from ' ]));
146
+ } elseif (
147
+ !empty ($ newPageData ['custom_theme_to ' ]) &&
148
+ date ("Y-m-d " , strtotime ($ postData ['custom_theme_to ' ])) ===
149
+ date ("Y-m-d " , strtotime ($ pageData ['custom_theme_to ' ]))
150
+ ) {
151
+ $ newPageData ['custom_theme_to ' ] = date ("Y-m-d " , strtotime ($ postData ['custom_theme_to ' ]));
152
+ }
153
+ return $ newPageData ;
154
+ }
155
+
130
156
/**
131
157
* Validate post data
132
158
*
0 commit comments