Skip to content

Commit ab23533

Browse files
authored
Merge pull request #4776 from magento-tango/MC-13827
MC-13827: Failed funtional test Magento\FunctionalTestingFramework.functional.StorefrontSortingByPriceForConfigurableProductWithCatalogRuleAppliedTest
2 parents 12ee2b3 + 40c4fac commit ab23533

File tree

1 file changed

+14
-4
lines changed
  • app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog

1 file changed

+14
-4
lines changed

app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog/Save.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\Registry;
1212
use Magento\Framework\Stdlib\DateTime\Filter\Date;
1313
use Magento\Framework\App\Request\DataPersistorInterface;
14+
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1415

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

26+
/**
27+
* @var TimezoneInterface
28+
*/
29+
private $localeDate;
30+
2531
/**
2632
* @param Context $context
2733
* @param Registry $coreRegistry
2834
* @param Date $dateFilter
2935
* @param DataPersistorInterface $dataPersistor
36+
* @param TimezoneInterface $localeDate
3037
*/
3138
public function __construct(
3239
Context $context,
3340
Registry $coreRegistry,
3441
Date $dateFilter,
35-
DataPersistorInterface $dataPersistor
42+
DataPersistorInterface $dataPersistor,
43+
TimezoneInterface $localeDate
3644
) {
3745
$this->dataPersistor = $dataPersistor;
46+
$this->localeDate = $localeDate;
3847
parent::__construct($context, $coreRegistry, $dateFilter);
3948
}
4049

4150
/**
4251
* @return void
4352
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
53+
* @SuppressWarnings(PHPMD.NPathComplexity)
4454
*/
4555
public function execute()
4656
{
4757
if ($this->getRequest()->getPostValue()) {
48-
4958
/** @var \Magento\CatalogRule\Api\CatalogRuleRepositoryInterface $ruleRepository */
5059
$ruleRepository = $this->_objectManager->get(
5160
\Magento\CatalogRule\Api\CatalogRuleRepositoryInterface::class
5261
);
53-
5462
/** @var \Magento\CatalogRule\Model\Rule $model */
5563
$model = $this->_objectManager->create(\Magento\CatalogRule\Model\Rule::class);
5664

@@ -60,7 +68,9 @@ public function execute()
6068
['request' => $this->getRequest()]
6169
);
6270
$data = $this->getRequest()->getPostValue();
63-
71+
if (!$this->getRequest()->getParam('from_date')) {
72+
$data['from_date'] = $this->localeDate->formatDate();
73+
}
6474
$filterValues = ['from_date' => $this->_dateFilter];
6575
if ($this->getRequest()->getParam('to_date')) {
6676
$filterValues['to_date'] = $this->_dateFilter;

0 commit comments

Comments
 (0)