0

I want to join my order table with the Magento order table to display data on my custom grid. The correct way to add fields to a DataProvider is by using addFieldStrategies and addFilterStrategies via di.xml.

  • di.xml
        <type name="MyVendor\MyModule\Ui\DataProvider\Order\DataProvider">
                <arguments>
                    <argument name="addFieldStrategies" xsi:type="array">
                        <item name="reason" xsi:type="object">MyVendor\MyModule\Ui\DataProvider\Order\Grid\Strategies\AddReasonFieldToCollection</item>
                    </argument>
                    <argument name="addFilterStrategies" xsi:type="array">
                        <item name="reason" xsi:type="object">MyVendor\MyModule\Ui\DataProvider\Order\Grid\Strategies\AddReasonFilterToCollection</item>
                    </argument>
                </arguments>
        </type>

I can add only one field via this method, though I want to join 4 field as in

  • Dataprovider.php
$this->collection->getSelect()->joinLeft(
            ['sales' => $this->collection->getTable('sales_order_grid')],
            'main_table.magento_order_id = sales.entity_id',
            [
                'sales.store_id',
                'sales.shipping_name',
                'sales.billing_name',
                'sales.base_grand_total',
                'sales.status as magento_status'
            ]
        );

What is the correct way to move this multi-field join to implement via addFieldStrategies and addFilterStrategies via di.xml?

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.