![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-catalog/Observer/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Catalog\Observer; use Magento\Framework\Event\ObserverInterface; use Magento\Framework\Stdlib\DateTime\TimezoneInterface; /** * Set value for Special Price start date */ class SetSpecialPriceStartDate implements ObserverInterface { /** * @var TimezoneInterface */ private $localeDate; /** * @param TimezoneInterface $localeDate */ public function __construct(TimezoneInterface $localeDate) { $this->localeDate = $localeDate; } /** * Set the current date to Special Price From attribute if it's empty. * * @param \Magento\Framework\Event\Observer $observer * @return $this */ public function execute(\Magento\Framework\Event\Observer $observer) { /** @var $product \Magento\Catalog\Model\Product */ $product = $observer->getEvent()->getProduct(); if ($product->getSpecialPrice() && $product->getSpecialFromDate() === null) { $product->setData('special_from_date', $this->localeDate->date()->setTime(0, 0)); } return $this; } }