Search code examples
magentoconfigurationattributesmagento2

I need to remove the two fields as mentioned in the screenshot from Magento 2


As you can see in the screenshot, we have skin type and product brand with an asterik. Removing Product name and Skin Type asterik fields

I have created a new attribute and I don't want these two field to be included in it. So how can I remove the field manually from the Magento dashboard or I can make it not mandatory to add.

Currently I have dragged skin type from Stores->Product Attributes->Groups to unassigned attributes.


Solution

  • 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