|
| 1 | +--- Observer/UpdateProductDateAttributes.php 2019-02-14 14:46:57.128821255 +0300 |
| 2 | ++++ Observer/UpdateProductDateAttributes.php 2019-02-14 14:46:43.893157971 +0300 |
| 3 | +@@ -98,10 +98,20 @@ |
| 4 | + { |
| 5 | + $product = $observer->getEvent()->getProduct(); |
| 6 | + $version = $this->versionManager->getCurrentVersion(); |
| 7 | +- |
| 8 | ++ /* |
| 9 | ++ * Removed date conversion and formatting |
| 10 | ++ * $localStartTime = $this->localeDate->date($version->getStartTime()); |
| 11 | ++ * $this->setDateTime($product, self::$startDateKeys, $localStartTime->format(DateTime::DATETIME_PHP_FORMAT))); |
| 12 | ++ * because we need get a date from DB in the correct DB format (timestamp), and put it into other DB record. |
| 13 | ++ * When we convert timestam string in to DataTime object over "$this->localeDate->date", we can break a date, |
| 14 | ++ * because it converter use locale and if system locale format disagree with timestamp format, conversion can |
| 15 | ++ * break the date (return object with wrong date). If we be pass locale of string into the |
| 16 | ++ * "$this->localeDate->date", as a result, we get exactly the same date. So we don`t need a convert date, |
| 17 | ++ * we can use timestamp date as it is. |
| 18 | ++ * Conversion in this case is an extra code that can lead to errors and waste time. |
| 19 | ++ */ |
| 20 | + if ($version->getStartTime()) { |
| 21 | +- $localStartTime = $this->localeDate->date($version->getStartTime()); |
| 22 | +- $this->setDateTime($product, self::$startDateKeys, $localStartTime->format(DateTime::DATETIME_PHP_FORMAT)); |
| 23 | ++ $this->setDateTime($product, self::$startDateKeys, $version->getStartTime()); |
| 24 | + } else { |
| 25 | + $date = $product->getData('is_new') |
| 26 | + ? $this->localeDate->date()->format(DateTime::DATETIME_PHP_FORMAT) |
| 27 | +@@ -110,8 +120,7 @@ |
| 28 | + } |
| 29 | + |
| 30 | + if ($version->getEndTime()) { |
| 31 | +- $localEndTime = $this->localeDate->date($version->getEndTime()); |
| 32 | +- $this->setDateTime($product, self::$endDateKeys, $localEndTime->format(DateTime::DATETIME_PHP_FORMAT)); |
| 33 | ++ $this->setDateTime($product, self::$endDateKeys, $version->getEndTime()); |
| 34 | + } else { |
| 35 | + $this->setDateTime($product, self::$endDateKeys, null); |
| 36 | + } |
0 commit comments