From eb98a8ddb7f7b4589413cc5e56142e0113411aa2 Mon Sep 17 00:00:00 2001 From: Korobov Danil Date: Thu, 14 Feb 2019 15:05:08 +0300 Subject: [PATCH] [MYL-380] fix changing the date depending on the locale --- Patch-Magento_Catalog_Staging-timestam.patch | 36 ++++++++++++++++++++ README.md | 6 +++- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 Patch-Magento_Catalog_Staging-timestam.patch diff --git a/Patch-Magento_Catalog_Staging-timestam.patch b/Patch-Magento_Catalog_Staging-timestam.patch new file mode 100644 index 0000000..4944018 --- /dev/null +++ b/Patch-Magento_Catalog_Staging-timestam.patch @@ -0,0 +1,36 @@ +--- Observer/UpdateProductDateAttributes.php 2019-02-14 14:46:57.128821255 +0300 ++++ Observer/UpdateProductDateAttributes.php 2019-02-14 14:46:43.893157971 +0300 +@@ -98,10 +98,20 @@ + { + $product = $observer->getEvent()->getProduct(); + $version = $this->versionManager->getCurrentVersion(); +- ++ /* ++ * Removed date conversion and formatting ++ * $localStartTime = $this->localeDate->date($version->getStartTime()); ++ * $this->setDateTime($product, self::$startDateKeys, $localStartTime->format(DateTime::DATETIME_PHP_FORMAT))); ++ * because we need get a date from DB in the correct DB format (timestamp), and put it into other DB record. ++ * When we convert timestam string in to DataTime object over "$this->localeDate->date", we can break a date, ++ * because it converter use locale and if system locale format disagree with timestamp format, conversion can ++ * break the date (return object with wrong date). If we be pass locale of string into the ++ * "$this->localeDate->date", as a result, we get exactly the same date. So we don`t need a convert date, ++ * we can use timestamp date as it is. ++ * Conversion in this case is an extra code that can lead to errors and waste time. ++ */ + if ($version->getStartTime()) { +- $localStartTime = $this->localeDate->date($version->getStartTime()); +- $this->setDateTime($product, self::$startDateKeys, $localStartTime->format(DateTime::DATETIME_PHP_FORMAT)); ++ $this->setDateTime($product, self::$startDateKeys, $version->getStartTime()); + } else { + $date = $product->getData('is_new') + ? $this->localeDate->date()->format(DateTime::DATETIME_PHP_FORMAT) +@@ -110,8 +120,7 @@ + } + + if ($version->getEndTime()) { +- $localEndTime = $this->localeDate->date($version->getEndTime()); +- $this->setDateTime($product, self::$endDateKeys, $localEndTime->format(DateTime::DATETIME_PHP_FORMAT)); ++ $this->setDateTime($product, self::$endDateKeys, $version->getEndTime()); + } else { + $this->setDateTime($product, self::$endDateKeys, null); + } diff --git a/README.md b/README.md index fb0c41e..430d9ee 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ magento/module-catalog-inventory|Patch-Magento\_CatalogInventory-M2.1.x-stock-it magento/module-catalog-inventory|Patch-Magento_CatalogInventory-M2.2.0-2.2.3-fix-update-stock-item-on-product-save.patch|Fix: Update stock item on product save|>=2.2.0 <2.2.4 magento/module-catalog-inventory|Patch-Magento_CatalogInventory-M2.2.0-2.2.4-stock-index.patch|#12205|>=2.2.0 <2.2.5 magento/module-catalog-rule|Patch-Magento-Catalog-Rule-M2.1.X-cron-job.patch|Q-67970|>= 2.1.0 >= 2.2.0 +magento/module-catalog-staging|Patch-Magento_Catalog_Staging-timestam.patch| | ? magento/module-catalog-url-rewrite|Patch-Magento\_CatalogUrlRewrite-M2.1.4-regeneration-without-changes-fix.patch (install 2 patches *-regeneration-without-changes-fix)|#7874|>=2.1.4 < 2.1.9 magento/module-catalog-widget|Patch-Magento\_CatalogWidget-M2.1.0-widgets-restore-conditions.patch|#2913|< 2.1.8 (2.1.4 n/a) magento/module-swatches|Patch-Magento\_Swatches-rest-api-visual-swatches-fix.patch| |>= 2.1.4 @@ -82,7 +83,7 @@ magento/module-configurable-product|Patch-Magento_ConfigurableProduct-M2.2.x-fix magento/module-configurable-product|Patch-Magento_ConfigurableProduct-M2.2.x-fix-min-max-prices_M2.2.6.patch|#15654|>=2.2.6 magento/module-configurable-product|Patch-Magento_Configurable_M2.1.x-fix-get-price.patch|#5519|<2.1.10 magento/module-cache-invalidate|Patch-Magento_CacheInvalidate-M2.1.x-purge-cache.patch|#7614|<2.2 -magento/module-config|Patch-Magento_Config-Fix-of-Saving-clone-field-M2.2.6.patch|#19070| 2.2.5 2.2.6 +magento/module-config|Patch-Magento_Config-Fix-of-Saving-clone-field-M2.2.6.patch|#19070| 2.2.5 2.2.6 **3th party modules:** @@ -175,6 +176,9 @@ Full composer.json example: "magento/module-catalog-rule": { "Fix: https://magento.stackexchange.com/questions/67970/catalog-price-rules-disappear-after-mid-night": "https://raw.githubusercontent.com/ConvertGroupsAS/magento2-patches/master/Patch-Magento-Catalog-Rule-M2.1.X-cron-job.patch" }, + "magento/module-catalog-staging": { + "Fix: changing the date depending on the locale": "https://raw.githubusercontent.com/ConvertGroupsAS/magento2-patches/master/Patch-Magento_Catalog_Staging-timestam.patch" + }, "magento/module-catalog-widget": { "Fix: https://github.com/magento/magento2/issues/2913": "https://raw.githubusercontent.com/ConvertGroupsAS/magento2-patches/master/Patch-Magento_CatalogWidget-M2.1.0-widgets-restore-conditions.patch" },