Magento 2 : How to add Custom link product Attribute in Custom product link grid
-
27-12-2020 - |
Вопрос
I have added new custom product link type and it working fine. I want to add some custom attribute to it grid and in grid i want to give text box option for enter custom attribute value and when product save at that time i want to save it.
Any help will be appreciated. Thank you.
Решение
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']
Не связан с magento.stackexchange