Finnaly i got solution
I overide Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Related.php
di.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<preference for="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Related"
type="Test\TestRelation\Ui\DataProvider\Product\Form\Modifier\Related"/>
</config>
enter code here
Ui\DataProvider\Product\Form\Modifier\Related.php
In this file i override fillMeta() function
/**
* Retrieve meta column
*
* @return array
* @since 101.0.0
*/
protected function fillMeta() {
return [
'id' => $this->getTextColumn('id', false, __('ID'), 0),
'thumbnail' => [
'arguments' => [
'data' => [
'config' => [
'componentType' => Field::NAME,
'formElement' => Input::NAME,
'elementTmpl' => 'ui/dynamic-rows/cells/thumbnail',
'dataType' => Text::NAME,
'dataScope' => 'thumbnail',
'fit' => true,
'label' => __('Thumbnail'),
'sortOrder' => 10,
],
],
],
],
'name' => $this->getTextColumn('name', false, __('Name'), 20),
'status' => $this->getTextColumn('status', true, __('Status'), 30),
'attribute_set' => $this->getTextColumn('attribute_set', false, __('Attribute Set'), 40),
'sku' => $this->getTextColumn('sku', true, __('SKU'), 50),
'price' => $this->getTextColumn('price', true, __('Price'), 60),
'actionDelete' => [
'arguments' => [
'data' => [
'config' => [
'additionalClasses' => 'data-grid-actions-cell',
'componentType' => 'actionDelete',
'dataType' => Text::NAME,
'label' => __('Actions'),
'sortOrder' => 70,
'fit' => true,
],
],
],
],
'position' => [
'arguments' => [
'data' => [
'config' => [
'dataType' => Number::NAME,
'formElement' => Input::NAME,
'componentType' => Field::NAME,
'dataScope' => 'position',
'sortOrder' => 80,
'visible' => false,
],
],
],
],
'sidea' => [
'arguments' => [
'data' => [
'config' => [
'dataType' => Number::NAME,
'formElement' => Input::NAME,
'componentType' => Field::NAME,
'label' => __('Side A'),
'sortOrder' => 80,
],
],
],
],
'sideb' => [
'arguments' => [
'data' => [
'config' => [
'dataType' => Number::NAME,
'formElement' => Input::NAME,
'componentType' => Field::NAME,
'label' => __('Side B'),
'sortOrder' => 90,
],
],
],
],
'sidec' => [
'arguments' => [
'data' => [
'config' => [
'dataType' => Number::NAME,
'formElement' => Input::NAME,
'componentType' => Field::NAME,
'label' => __('Side C'),
'sortOrder' => 100,
'editorConfig' => ['editorType' => 'text']
],
],
],
],
'sided' => [
'arguments' => [
'data' => [
'config' => [
'dataType' => Number::NAME,
'formElement' => Input::NAME,
'componentType' => Field::NAME,
'label' => __('Side D'),
'sortOrder' => 110,
'editorConfig' => ['editorType' => 'text']
],
],
],
],
];
}
For Add Editor Option,
In Cross Sell etc or Custom Product Link option
Need to set editorConfig property of column so it display Text Box,
'editorConfig' => ['editorType' => 'text']
Best Answer
First of all...nice question. Got me really interested.
Here is an example on how you can create an attribute that has a custom renderer (template) and the value is saved serialized.
For this example I created an attribute that will have 2 text inputs, but you can basically put anything in there.
I recommend creating a custom module to handle your attribute. Let's call this extension
Easylife_Attr
.You will need the following files.
app/etc/module/Easylife_Attr.xml
- the declaration file.app/code/local/Easylife/Attr/etc/config.xml
- the configuration fileapp/code/local/Easylife/Attr/sql/easylife_attr_setup/install-0.0.1.php
- the install script. It will add your attributeNow the fun part.
app/code/local/Easylife/Attr/Model/Observer.php
- the observe that will change the attribute templateapp/code/local/Easylife/Attr/Block/Adminhtml/Product/Custom.php
- the custom renderer blockapp/design/adminhtml/default/default/template/easylife_attr/product/custom.phtml
- the template for the attribute.app/code/local/Easylife/Attr/Model/Custom.php
- the model that handles the serialization and deserialization.That's it. Here is how the attribute would look in the backend: