Skip to content

Commit f141912

Browse files
authored
ENGCOM-5341: [Backport] Remove timestap from current date when saving product special price from date #23152
2 parents 7bb2644 + c082361 commit f141912

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

app/code/Magento/Catalog/Observer/SetSpecialPriceStartDate.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,33 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Catalog\Observer;
79

810
use Magento\Framework\Event\ObserverInterface;
11+
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
912

1013
/**
1114
* Set value for Special Price start date
1215
*/
1316
class 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

Comments
 (0)