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.

Edit Product in magento backend

I think this can be done using adminhtml/ui_component/product_form.xml file, but don't know how.


2 Answers 2


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" />

Step 2: Create file fieldhide.phtml under app/code/Vendor/Module/view/adminhtml/templates/product/edit

File : fieldhide.phtml

    ], function($,uiRegistry){
        uiRegistry.get("product_form.product_form.content.container_yourcustomfield.yourcustomfield", function (element) {

Note : Please replace "yourcustomfield" with your attribute code

Step 3: Please remove static files and refresh cache

  • Thank you for your answer, I'll try this and update you regarding its result.
    – Knight017
    Dec 11, 2018 at 8:34
  • I have tried your way but unable to have the desired result, I have done and cleared cache like rm -rf pub/static/* var/di/* var/cache/* var/page_cache/* generated/* var/view_preprocessed/* && php -dmemory_limit=6G bin/magento setup:upgrade && php -dmemory_limit=6G bin/magento setup:static-content:deploy -f
    – Knight017
    Dec 11, 2018 at 9:35
  • can you please confirm JS is working or not . Also make sure you replace yourcustomfield.yourcustomfield with your field id. For that please right click and use View Source tool of your browser. Dec 11, 2018 at 9:41
  • I have checked the file does not called at all. I have add console.log() after first line of script tag.
    – Knight017
    Dec 11, 2018 at 9:53
  • How can i remove a custom field in account informaion in admin area? Feb 12, 2020 at 10:19

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.