@@ -83,9 +83,9 @@ public function execute()
8383 /** @var \Magento\Cms\Model\Page $page */
8484 $ page = $ this ->pageRepository ->getById ($ pageId );
8585 try {
86- $ pageData = $ this ->filterPost ($ postItems [$ pageId ]);
87- $ this ->validatePost ($ pageData , $ page , $ error , $ messages );
8886 $ extendedPageData = $ page ->getData ();
87+ $ pageData = $ this ->filterPostWithDateConverting ($ postItems [$ pageId ], $ extendedPageData );
88+ $ this ->validatePost ($ pageData , $ page , $ error , $ messages );
8989 $ this ->setCmsPageData ($ page , $ extendedPageData , $ pageData );
9090 $ this ->pageRepository ->save ($ page );
9191 } catch (\Magento \Framework \Exception \LocalizedException $ e ) {
@@ -127,6 +127,34 @@ protected function filterPost($postData = [])
127127 return $ pageData ;
128128 }
129129
130+ /**
131+ * Filtering posted data with converting custom theme dates to proper format
132+ *
133+ * @param array $postData
134+ * @param array $pageData
135+ * @return array
136+ */
137+ private function filterPostWithDateConverting ($ 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+ }
147+ if (
148+ !empty ($ newPageData ['custom_theme_to ' ])
149+ && date ("Y-m-d " , strtotime ($ postData ['custom_theme_to ' ]))
150+ === date ("Y-m-d " , strtotime ($ pageData ['custom_theme_to ' ]))
151+ ) {
152+ $ newPageData ['custom_theme_to ' ] = date ("Y-m-d " , strtotime ($ postData ['custom_theme_to ' ]));
153+ }
154+
155+ return $ newPageData ;
156+ }
157+
130158 /**
131159 * Validate post data
132160 *
0 commit comments