forked from magento/magento2
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAGETWO-52577: [GitHub] Set Product as New from Date and Design Activ…
…e From is set when setting Special Price magento#4387
- Loading branch information
Showing
7 changed files
with
83 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
app/code/Magento/Catalog/Observer/SetSpecialPriceStartDate.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
/** | ||
* Copyright © 2013-2017 Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Catalog\Observer; | ||
|
||
use Magento\Framework\Event\ObserverInterface; | ||
|
||
/** | ||
* Set value for Special Price start date | ||
*/ | ||
class SetSpecialPriceStartDate implements ObserverInterface | ||
{ | ||
/** | ||
* @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface | ||
*/ | ||
private $localeDate; | ||
|
||
/** | ||
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate | ||
* @codeCoverageIgnore | ||
*/ | ||
public function __construct(\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate) | ||
{ | ||
$this->localeDate = $localeDate; | ||
} | ||
|
||
/** | ||
* Set the current date to Special Price From attribute if it 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()) { | ||
$product->setData('special_from_date', $this->localeDate->date()); | ||
} | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters