I am using Magento 2.2.5
I need to hide a text attribute which I'm using to save serialized data of custom options of product.
I think this can be done using adminhtml/ui_component/product_form.xml
file, but don't know how.
Thanks
You can try below steps to hide product fields
Step 1:
create catalog_product_edit.xml under app/code/Vendor/Module/view/adminhtml/layout
File : catalog_product_edit.xml
<referenceContainer name="content">
<block class="Magento\Framework\View\Element\Template" name="myattribHide" before="before.body.end" template="Vendor_Module::product/edit/fieldhide.phtml" />
</referenceContainer>
Step 2: Create file fieldhide.phtml under app/code/Vendor/Module/view/adminhtml/templates/product/edit
File : fieldhide.phtml
<script>
require([
'jquery',
'uiRegistry'
], function($,uiRegistry){
uiRegistry.get("product_form.product_form.content.container_yourcustomfield.yourcustomfield", function (element) {
element.hide();
});
})
</script>
Note : Please replace "yourcustomfield" with your attribute code
Step 3: Please remove static files and refresh cache
I have added below line in my install script to not display the attribute in product edit page in admin.
$installer->updateAttribute('catalog_product', $attribute_code, 'is_visible', '0');
I have found the Hide Attributes and Other Fields in Product Edit Backend reference from an older question.
CAUTION :: With this approach, I'm not able to display saved serialized data in fields.
This question is related with my other question in which I have mentioned how to save product's custom options in serialized form in attribute How to save serialized data in product's text backend_type custom attribute.