33 * Copyright © Magento, Inc. All rights reserved.
44 * See COPYING.txt for license details.
55 */
6+ declare (strict_types=1 );
7+
68namespace Magento \Catalog \Observer ;
79
810use Magento \Framework \Event \ObserverInterface ;
11+ use Magento \Framework \Stdlib \DateTime \TimezoneInterface ;
912
1013/**
1114 * Set value for Special Price start date
1215 */
1316class SetSpecialPriceStartDate implements ObserverInterface
1417{
1518 /**
16- * @var \Magento\Framework\Stdlib\DateTime\ TimezoneInterface
19+ * @var TimezoneInterface
1720 */
1821 private $ localeDate ;
1922
2023 /**
21- * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
22- * @codeCoverageIgnore
24+ * @param TimezoneInterface $localeDate
2325 */
24- public function __construct (\ Magento \ Framework \ Stdlib \ DateTime \ TimezoneInterface $ localeDate )
26+ public function __construct (TimezoneInterface $ localeDate )
2527 {
2628 $ this ->localeDate = $ localeDate ;
2729 }
2830
2931 /**
30- * Set the current date to Special Price From attribute if it empty
32+ * Set the current date to Special Price From attribute if it's empty.
3133 *
3234 * @param \Magento\Framework\Event\Observer $observer
3335 * @return $this
@@ -36,8 +38,8 @@ public function execute(\Magento\Framework\Event\Observer $observer)
3638 {
3739 /** @var $product \Magento\Catalog\Model\Product */
3840 $ product = $ observer ->getEvent ()->getProduct ();
39- if ($ product ->getSpecialPrice () && !$ product ->getSpecialFromDate ()) {
40- $ product ->setData ('special_from_date ' , $ this ->localeDate ->date ());
41+ if ($ product ->getSpecialPrice () && ! $ product ->getSpecialFromDate ()) {
42+ $ product ->setData ('special_from_date ' , $ this ->localeDate ->date ()-> setTime ( 0 , 0 ) );
4143 }
4244
4345 return $ this ;
0 commit comments