-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Entered data missing when entering the wrong date for from, to in cart rule #20895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
3da7c76
d697ea6
8faf8e9
e5abf95
811a7bf
89a5728
1a69d43
bc92929
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
use Magento\SalesRule\Model\ResourceModel\Rule\Collection; | ||
use Magento\SalesRule\Model\ResourceModel\Rule\CollectionFactory; | ||
use Magento\SalesRule\Model\Rule; | ||
use Magento\Framework\App\Request\DataPersistorInterface; | ||
|
||
/** | ||
* Class DataProvider | ||
|
@@ -35,6 +36,11 @@ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider | |
* @var \Magento\SalesRule\Model\Rule\Metadata\ValueProvider | ||
*/ | ||
protected $metadataValueProvider; | ||
|
||
/** | ||
* @var DataPersistorInterface | ||
*/ | ||
protected $dataPersistor; | ||
realadityayadav marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* Initialize dependencies. | ||
|
@@ -45,6 +51,7 @@ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider | |
* @param CollectionFactory $collectionFactory | ||
* @param \Magento\Framework\Registry $registry | ||
* @param Metadata\ValueProvider $metadataValueProvider | ||
* @param DataPersistorInterface $dataPersistor | ||
* @param array $meta | ||
* @param array $data | ||
*/ | ||
|
@@ -55,13 +62,15 @@ public function __construct( | |
CollectionFactory $collectionFactory, | ||
\Magento\Framework\Registry $registry, | ||
\Magento\SalesRule\Model\Rule\Metadata\ValueProvider $metadataValueProvider, | ||
DataPersistorInterface $dataPersistor, | ||
realadityayadav marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add this dependency in a backward compatible way, see "Adding a parameter to Constructor" section of https://devdocs.magento.com/guides/v2.3/contributor-guide/backward-compatible-development/#php There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added the necessary changes @sivaschenko |
||
array $meta = [], | ||
array $data = [] | ||
) { | ||
$this->collection = $collectionFactory->create(); | ||
$this->coreRegistry = $registry; | ||
$this->metadataValueProvider = $metadataValueProvider; | ||
$meta = array_replace_recursive($this->getMetadataValues(), $meta); | ||
$this->dataPersistor = $dataPersistor; | ||
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data); | ||
} | ||
|
||
|
@@ -93,6 +102,13 @@ public function getData() | |
|
||
$this->loadedData[$rule->getId()] = $rule->getData(); | ||
} | ||
$data = $this->dataPersistor->get('sale_rule'); | ||
if (!empty($data)) { | ||
$rule = $this->collection->getNewEmptyItem(); | ||
$rule->setData($data); | ||
$this->loadedData[$rule->getId()] = $rule->getData(); | ||
$this->dataPersistor->clear('sale_rule'); | ||
} | ||
|
||
return $this->loadedData; | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.