Posted on

Magento 2 how to get DataRange filter value?

I have added a DataRange filter like this on a listing ui component:

<column name=”fecha_order” sortOrder=”20″>
<settings>
<filter>dateRange</filter>
<label translate=”true”>Fecha</label>
</settings>
</column>

Then I get the values here in a custom Data Provider

public function addFilter(MagentoFrameworkApiFilter $filter)
{
$writer = new LaminasLogWriterStream(BP . ‘/var/log/filters.log’);
$logger = new LaminasLogLogger();
$logger->addWriter($writer);

$this->_session->start();
$this->_session->setFrom($filter->getValue());
$logger->info($filter->getValue());
$logger->info($filter->getField());
}

The only problem is that I’m getting both values like 1 single variable.
I get for example:
2021-09-01 05:00:00
2021-09-15 04:59:59

So the method is like executing 2 times.

But I need to get both in a single time because I’m storing it on a Session Variable.
I need to create a variable session From and a variable session To
How can I achieve that?
Thanks and greetings!

Leave a Reply

Your email address will not be published. Required fields are marked *