0

Lets say, Third party collection class is as below:

namespace Vendor\ShipRule\Model\ResourceModel\Rule;

class Collection extends Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
{
    protected function _construct()
    {
        $this->_init(\Vendor\ShipRule\Model\Rule::class, \Vendor\ShipRule\Model\ResourceModel\Rule::class);
        $this->_setIdFieldName($this->getResource()->getIdFieldName());
    }
}

and Ui component Listing XML (dataSource collection argument) is as below:

<dataSource name="vendor_shiprule_listing_data_source">
        <argument name="dataProvider" xsi:type="configurableObject">
            <argument name="name" xsi:type="string">vendor_shiprule_listing_data_source</argument>
            <argument name="primaryFieldName" xsi:type="string">rule_id</argument>
            <argument name="requestFieldName" xsi:type="string">id</argument>
            <argument name="collection" xsi:type="object">Vendor\ShipRule\Model\ResourceModel\Rule\Collection</argument>
...

If we want to add/show new table field in Existing UI Component Listing/Grid of Third Party extension. If we add below code into existing collection then that works, but that is not recommended. So here want elegant way for doing this.

protected function _initSelect()
    {
        parent::_initSelect();

        $this->getSelect()->joinLeft(
            ['bsmTable' => $this->getTable('best_shiprules_mapping')],
            'main_table.rule_id = bsmTable.rule_id',
            ['stop_rules_processing']
        );
        $this->addFilterToMap('rule_id', 'main_table.rule_id');
    }

Could you suggest Magento Recommended way (for adding/showing new table field in Existing UI Component Listing/Grid of Third Party extension) with the utilising dependency injection concept( 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.