In my module, I use the Listing (grid) UI component to render data from an array. The data for the grid is provided by a DataProvider.php class getData() method.
For some reason, when I use a simple testing array, the data is properly rendered. When I use the actual array that I want to use, the grid displays the message: We couldn't find any records.

I am very sure that both arrays have the same format, so both should work. Using print_r() to print the arrays, they look identical in format. gettype() returns array for both arrays.

My DataProvider.php:

public function getData()
        $orderIds = $this->_registry->registry("orderids");

        foreach ((array)$orderIds as $orderId) {

            $order = $this->_order->load($orderId);

            $orderInfo[] = [ // This array doesn't work
                "entity_id" => $order->getId(),
                "customer_firstname" => $order->getCustomerFirstname(),
                "customer_lastname" => $order->getCustomerLastname(),
                "customer_email" => $order->getCustomerEmail(),

        $test[] = [ // This test array works
            "entity_id" => 1,
            "customer_firstname" => "Foo",
            "customer_lastname" => "Bar",
            "customer_email" => "[email protected]",

        $data = [
            'totalRecords' => count($orderInfo), // $test works, $orderInfo doesn't
            'items' => array_values($orderInfo), // $test works, $orderInfo doesn't

        /** @var ModifierInterface $modifier */
        foreach ($this->modifiersPool->getModifiersInstances() as $modifier) {
            $data = $modifier->modifyData($data);
        return $data;

Short description of the code: Order IDs are stored in the registry, a foreach() loop loops over every order ID and loads the order objects for those IDs, order data is stored in the $orderInfo array, which should be used to provide data to the grid.

  • Only diff I see in your array is entity_id being string. Try changing "entity_id" => $order->getId(), to "entity_id" => (int)$order->getId(), and see if that helps. Mar 22, 2021 at 0:34
  • Hello, @AdarshKhatri. Unfortunately, it doesn't help. I just noticed that in the browser console I get the warning "JQMIGRATE: jQuery.parseJSON requires a valid JSON string". Do you think it has anything to do with this? Mar 22, 2021 at 8:55
  • Could be, try adding more than 1 $test array. Mar 22, 2021 at 22:29
  • I found the solution... It works when using Magento\Framework\App\Request\DataPersistor instead of the Registry to fetch the order IDs. I will post a full answer later today! But thank you for your time and help. Mar 23, 2021 at 5:58

1 Answer 1


I figured it out! The problem was that I was using Registry to pass the order IDs from my controller to the data provider.
Using Magento\Framework\App\Request\DataPersistor instead to pass the data is a working solution.
You can set the order ID array in the controller with $this->_dataPersistor->set("orderids", $orderIds);
And fetch them in the data provider with $orderIds = $this->_dataPersistor->get("orderids");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.