Skip to content

Magento 2 + Add inlineEdit feature in related products grid on admin product edit page

I want to add an inlineEdit feature same as admin customer grid, in related products grid on admin product edit page. For that I extended MagentoCatalogUiDataProviderProductFormModifierRelated class and overridden getGrid() function in following way:

<?php
class DisplayProductLinksAdmin extends MagentoCatalogUiDataProviderProductFormModifierRelated {
    ...
    protected function getGrid($scope): array
    {
        $parent = parent::getGrid($scope);

        if ($scope !== 'related') {
            return $parent;
        }

        $parent['arguments']['data']['config']['editorConfig'] = [
            'clientConfig' => [
                'saveUrl' => $this->urlBuilder->getUrl('custom/index/inlineEdit'),
                'validateBeforeSave' => false
            ],
            'indexField' => 'entity_id',
            'enabled' => true,
            'selectProvider' => 'related_product_listing.related_product_listing.product_columns.ids'
        ];
        $parent['arguments']['data']['config']['childDefaults'] = [
            'fieldAction' => [
                'provider' => 'related_product_listing.related_product_listing.product_columns_editor',
                'target' => 'startEdit',
                'params' => [
                    '0' => '${ $.$data.rowIndex }',
                    '1' => true
                ]
            ]
        ];
        $parent['arguments']['data']['config']['map']['custom_column'] = 'custom_column';
        $parent['children']['record']['children'] = $this->fillMeta();

        return $parent;
    }
    ...
}

I found most of the solutions to add inlineEdit using UI Compoenent, but however vendor/magento/module-catalog/view/adminhtml/ui_component/related_product_listing.xml is not calling in Magento 2.4.5, might be the grid may built from MagentoCatalogUiDataProviderProductFormModifierRelated class. Anyways, please help me to add inlineEdit feature using php class or any other way except UI Component.

Reference image of inlineEdit feature given in admin customer grid:
enter image description here

I want to add exactly the above one in related products grid here:

enter image description here

Thanks in anticipation.