Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SetSpecialPriceStartDate.php
Go to the documentation of this file.
1 <?php
7 
9 
14 {
18  private $localeDate;
19 
24  public function __construct(\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate)
25  {
26  $this->localeDate = $localeDate;
27  }
28 
35  public function execute(\Magento\Framework\Event\Observer $observer)
36  {
38  $product = $observer->getEvent()->getProduct();
39  if ($product->getSpecialPrice() && !$product->getSpecialFromDate()) {
40  $product->setData('special_from_date', $this->localeDate->date());
41  }
42 
43  return $this;
44  }
45 }
__construct(\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate)