title: Magento 2 UI dataprovider does not load data
body: <p>First I'm not a hardcore coder in Magento 2, so most likely I'm missing something. I did search the web but it seems that I can't find the solution. Hopefully somebody can help me here.</p>
  <p><strong>The situation</strong>
  I have created a custom module and I have a custom controller that must pull data from a custom table. To do this I have created a custom UI DataProvider that should pull the data. When I access the controller the params in the url are providing an internal ID. When I retreive this ID and create a simple search I do not get any values in my table. In this case the ID is 59. When I hardcode the ID in the search I do get results in my table.</p>
  <p>I tested with some debug print_r outputs the query and the items pulled and in both cases the data is present before returning the data in the function getData(). So at this point I really do not understand why it works when I hardcode the value 59, but it doesn't when I retreive it with getParam.</p>
  <p>I expect that maybe in some way I'm using the collection incorrect. If I add the same filter in the parent:: then I get an error and its seems its using the Magento product collection. The section where it goes wrong is:</p>
  <pre><code>    $items = $this-&gt;purchaseOrderItemCollection
          -&gt;addFieldToFilter('purchase_order_id', array('eq' =&gt; $id))
          //-&gt;addFieldToFilter('purchase_order_id', array('eq' =&gt; 59))
          -&gt;getData()
      ;
  </code></pre>
  <p>If I comment the addFieldToFilter with the $id and uncomment the line with hardcode 59 it works. I also tried here to set the value $id through the registery because maybe I thought Magento does not remember the data somewhere else, but this did not resolve the issue.</p>
  <p>Below my controller.</p>
  <pre><code>&lt;?php
  namespace DssSolutions\Management\Ui\DataProvider\PurchaseOrderItem;
  
  use DssSolutions\Management\Api\PurchaseOrderSalesOrderItemRepositoryInterface;
  use DssSolutions\Management\Model\PurchaseOrderSalesOrderItem\DataProvider;
  use DssSolutions\Management\Model\ResourceModel\PurchaseOrderItem;
  use DssSolutions\Management\Model\ResourceModel\PurchaseOrderSalesOrderItem;
  use DssSolutions\Management\Model\ResourceModel\PurchaseOrdersLines;
  use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
  use Magento\Framework\App\ObjectManager;
  use Magento\Store\Model\Store;
  use Magento\Ui\DataProvider\Modifier\ModifierInterface;
  use Magento\Ui\DataProvider\Modifier\PoolInterface;
  
  /**
  * Class ProductDataProvider
  *
  * @api
  * @since 100.0.2
  */
  class ReceiveOrderedProductDataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
  {
    /**
   * Product collection
   *
   * @var \DssSolutions\Management\Model\ResourceModel\PurchaseOrderItem\Collection
   */
  protected $collection;
  
  /**
   * @var \Magento\Ui\DataProvider\AddFieldToCollectionInterface[]
   */
  protected $addFieldStrategies;
  
  /**
   * @var \Magento\Ui\DataProvider\AddFilterToCollectionInterface[]
   */
  protected $addFilterStrategies;
  
  /**
   * @var PoolInterface
   */
  private $modifiersPool;
  
  /**
   * @var \Magento\Framework\App\Request\Http
   */
  protected $request;
  
  /**
   * @var PurchaseOrderItem\Collection
   */
  protected $purchaseOrderItemCollection;
  
  /**
   * @var \Magento\Framework\Registry
   */
  protected $_registry;
  
  /**
   * @param string $name
   * @param string $primaryFieldName
   * @param string $requestFieldName
   * @param CollectionFactory $collectionFactory
   * @param \Magento\Ui\DataProvider\AddFieldToCollectionInterface[] $addFieldStrategies
   * @param \Magento\Ui\DataProvider\AddFilterToCollectionInterface[] $addFilterStrategies
   * @param array $meta
   * @param array $data
   * @param PoolInterface|null $modifiersPool
   */
  public function __construct(
      $name,
      $primaryFieldName,
      $requestFieldName,
      CollectionFactory $collectionFactory,
      \Magento\Framework\App\Request\Http $request,
      \Magento\Framework\Registry $registry,
      \DssSolutions\Management\Model\ResourceModel\PurchaseOrderItem\Collection $purchaseOrderItemCollection,
      array $addFieldStrategies = [],
      array $addFilterStrategies = [],
      array $meta = [],
      array $data = [],
      PoolInterface $modifiersPool = null
  ) {
      parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
      $this-&gt;request = $request;
      $this-&gt;_registry = $registry;
      $this-&gt;purchaseOrderItemCollection = $purchaseOrderItemCollection;
      $this-&gt;collection = $collectionFactory-&gt;create();
      $this-&gt;addFieldStrategies = $addFieldStrategies;
      $this-&gt;addFilterStrategies = $addFilterStrategies;
      $this-&gt;modifiersPool = $modifiersPool ?: ObjectManager::getInstance()-&gt;get(PoolInterface::class);
  }
  
  /**
   * Get data
   *
   * @return array
   */
  public function getData()
  {
      if (!$this-&gt;getCollection()-&gt;isLoaded()) {
          $this-&gt;getCollection()-&gt;load();
      }
  
      $this-&gt;_registry-&gt;register('current_purchase_order', $this-&gt;request-&gt;getParam('purchase_id', null));
      $id = $this-&gt;_registry-&gt;registry('current_purchase_order');
  
      $items = $this-&gt;purchaseOrderItemCollection
          -&gt;addFieldToFilter('purchase_order_id', array('eq' =&gt; $id))
          //-&gt;addFieldToFilter('purchase_order_id', array('eq' =&gt; 59))
          -&gt;getData()
      ;
  
      $collectionCounter = 1;
      foreach ($items as $k =&gt; $product){
          $items[$k]['qty_receivable'] = ($product['qty_orderred'] - $product['qty_received']);
          $collectionCounter++;
      }
  
      $data = [
          'totalRecords' =&gt; $collectionCounter,
          'items' =&gt; array_values($items),
      ];
  
      /** @var ModifierInterface $modifier */
      foreach ($this-&gt;modifiersPool-&gt;getModifiersInstances() as $modifier) {
          $data = $modifier-&gt;modifyData($data);
      }
  
      return $data;
  }
  
  /**
   * Add field to select
   *
   * @param string|array $field
   * @param string|null $alias
   * @return void
   */
  public function addField($field, $alias = null)
  {
      if (isset($this-&gt;addFieldStrategies[$field])) {
          $this-&gt;addFieldStrategies[$field]-&gt;addField($this-&gt;getCollection(), $field, $alias);
      } else {
          parent::addField($field, $alias);
      }
  }
  
  /**
   * @inheritdoc
   */
  public function addFilter(\Magento\Framework\Api\Filter $filter)
  {
      if (isset($this-&gt;addFilterStrategies[$filter-&gt;getField()])) {
          $this-&gt;addFilterStrategies[$filter-&gt;getField()]
              -&gt;addFilter(
                  $this-&gt;getCollection(),
                  $filter-&gt;getField(),
                  [$filter-&gt;getConditionType() =&gt; $filter-&gt;getValue()]
              );
      } else {
          parent::addFilter($filter);
      }
  }
  
  /**
   * @inheritdoc
   * @since 103.0.0
   */
  public function getMeta()
  {
      $meta = parent::getMeta();
  
      /** @var ModifierInterface $modifier */
      foreach ($this-&gt;modifiersPool-&gt;getModifiersInstances() as $modifier) {
          $meta = $modifier-&gt;modifyMeta($meta);
      }
  
      return $meta;
  }
  </code></pre>
  <p>}</p>