I managed to display the shipment core grid using ui component on another magento admin page. Right now I would like to filter it, to add more where clauses and join it MAYBE with other tables.

This is my di.xml:

<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <argument name="collections" xsi:type="array">
            <item name="vendor_modulename_grid_data_source" xsi:type="string">Magento\Sales\Model\ResourceModel\Order\Shipment\Grid\Collection</item>

Having the above I get a list of shipments. And I need to add a where clause , something like , where order status = {with something}.

I believe I need to use a virtualType for it, so I tried with:

<virtualType name="Magento\Sales\Model\ResourceModel\Order\Shipment\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
        <argument name="mainTable" xsi:type="string">sales_shipment</argument>
        <argument name="resourceModel" xsi:type="string">path\to\my\custom\class</argument>

I 'm not sure if if having the file declared in the resource model: path\to\my\custom\class this part , is the correct approach. Would you please advice how can I achieve this goal ?

Thnx in advance!

  • Oh, so you need a static predefined filter for your collection to display on first page only shipments "for orders having status processing" and you have another similar page where you want to display this grid but with another static filter, like "for orders having status pending" - is it right? Jan 23 '20 at 13:31
  • Exactly ;) and maybe later extend it with other tables Jan 23 '20 at 13:37

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.