Skip to content

Commit

Permalink
Merge pull request magento#4801 from magento-trigger/MC-20236
Browse files Browse the repository at this point in the history
  • Loading branch information
irenelagno authored Sep 18, 2019
2 parents ab23533 + 380b734 commit 3510d97
Showing 1 changed file with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Magento\Framework\Registry;
use Magento\Framework\Stdlib\DateTime\Filter\Date;
use Magento\Framework\App\Request\DataPersistorInterface;
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Expand All @@ -23,42 +22,35 @@ class Save extends \Magento\CatalogRule\Controller\Adminhtml\Promo\Catalog
*/
protected $dataPersistor;

/**
* @var TimezoneInterface
*/
private $localeDate;

/**
* @param Context $context
* @param Registry $coreRegistry
* @param Date $dateFilter
* @param DataPersistorInterface $dataPersistor
* @param TimezoneInterface $localeDate
*/
public function __construct(
Context $context,
Registry $coreRegistry,
Date $dateFilter,
DataPersistorInterface $dataPersistor,
TimezoneInterface $localeDate
DataPersistorInterface $dataPersistor
) {
$this->dataPersistor = $dataPersistor;
$this->localeDate = $localeDate;
parent::__construct($context, $coreRegistry, $dateFilter);
}

/**
* @return void
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function execute()
{
if ($this->getRequest()->getPostValue()) {

/** @var \Magento\CatalogRule\Api\CatalogRuleRepositoryInterface $ruleRepository */
$ruleRepository = $this->_objectManager->get(
\Magento\CatalogRule\Api\CatalogRuleRepositoryInterface::class
);

/** @var \Magento\CatalogRule\Model\Rule $model */
$model = $this->_objectManager->create(\Magento\CatalogRule\Model\Rule::class);

Expand All @@ -68,9 +60,7 @@ public function execute()
['request' => $this->getRequest()]
);
$data = $this->getRequest()->getPostValue();
if (!$this->getRequest()->getParam('from_date')) {
$data['from_date'] = $this->localeDate->formatDate();
}

$filterValues = ['from_date' => $this->_dateFilter];
if ($this->getRequest()->getParam('to_date')) {
$filterValues['to_date'] = $this->_dateFilter;
Expand Down

0 comments on commit 3510d97

Please sign in to comment.