0

I have a listing ui component and I need to send parameters. this is my listing.xml

<dataSource name="insert_listing_example_data_source" component="Magento_Ui/js/grid/provider">
        <settings>
            <updateUrl path="mui/index/render"/>
            <item name="filter_url_params" xsi:type="array">
                <item name="order_number" xsi:type="string">*</item>
            </item>
                 <item name="storageConfig" xsi:type="array">
                    <item name="indexField" xsi:type="string">order_number</item>
                </item>
        </settings>
        <dataProvider class="Vendor\Reports\Ui\Component\Listing\MonitorDataProvider" name="insert_listing_example_data_source">
            <settings>
                <requestFieldName>id</requestFieldName>
                <primaryFieldName>order_number</primaryFieldName>
            </settings>
        </dataProvider>
    </dataSource>

Then inside Vendor\Reports\Ui\Component\Listing\MonitorDataProvider

I try the following:

 public function getData(){

        $writer = new \Laminas\Log\Writer\Stream(BP . '/var/log/filters.log');
        $logger = new \Laminas\Log\Logger();
        $logger->addWriter($writer);
        $param = $this->request->getParam('order_number');
     

        return $this->getCollection()->toArray();
   }

But it's just blank, I'm not getting the filter theres. I need to get the filters on getData() otherwise grid won't update.

I have tried with

 public function addFilter(\Magento\Framework\Api\Filter $filter)
    {
       
        $logger->info($filter->getField()); 
        $logger->info($filter->getValue()); 
       parent::addFilter($filter);
    
    }

But this method does not updates my getData() even if I filter my collection, so I need to get the parameters directly in getData()

Greetings!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.