We can change/add inputs by below files :
adminhtml/default/default/template/catalog/product/attribute/options.phtml
adminhtml/default/default/template/catalog/product/attribute/js.phtml
Yes it will return same data as that data needs to be filter to get actual html.
It's kind of same data as cms page or block have all textarea type attribute data needs to be filter to get actual rendered value.
So do one thing in layout, pass viewmodel argument inside your block for which you have that template.
Like this:
<arguments> <argument name="viewModel" xsi:type="object">Namespace\ModuleName\ViewModel\Product</argument> </arguments>
Create a class as specified in view model argument and inside class you need to use :
use Magento\Cms\Model\Template\FilterProvider;
Then declare it in constructor
And create a function to call from template and inside function use it like:
$this->filterProvider->getPageFilter()->filter($_product->getTest());
Then you can call your viewModel inside template like this:
$viewModel = $block->getViewModel();
And call your function from $viewModel
.
For detail about viewModel you can check here
You can create an helper and call it directly from template same thing (as stated above for class) can be used in helper class as well.
Best Answer
Magento 2: Changing Product Attribute Type Admin does not allow you to change the attribute type once it is created and values have been entered. But as mentioned above we can achieve this
programmatically.We have to do this without losing the existing attribute values that (in the above example) have been entered for 1000 products.
When the attribute is in “Text”, the product value of this attribute is stored in the “catalog_product_entity_varchar”, but when we change the attribute type as “Dropdown”, the product value will be stored in “catalog_product_entity_int”. By using the below code we can change the product attribute type from text box to drop down in a short time without losing the existing values.
Place this code in the root directory of Magento 2 files and execute it.
How To Execute This Code?
Step 1 – Copy the above code and paste the same in a new file called sample.php in the Magento 2 root directory.
Step 2 – Execute the sample.php file by entering the browser URL along with the file name (example – www.yourdomainname.com/sample.php)
Step 3 – Once the above code is executed, please do not forget to reindex and also clear all the cache.
Hope this will help you out