Menu Close
    Hire us Request quote Reading list Switch to dark mode

    Create Product File Type Attribute in Magento 2

    Create Product File Type Attribute in Magento 2: – In this blog we are going to create and manage product file type attribute in magento 2.

    Follow the below steps in order to create file type attribute:

    Step 1:

    First of all we have to create a product attribute with input type “File”. Here I’m creating it by installer. So, create a InstallData.php file in /app/code/Vendor/Module/Setup directory and copy below code.

    Step 2:

    Then create backend model File.php(which we have defined in attribute options) in app/code/Vendor/Module/Model/Product/Attribute/Backend directory and copy below code.

    Step 3:

    To display saved file, we need to define template for the attribute. So, first define modifier class of the attribute in app/code/Vendor/Module/etc/adminhtml/di.xml as mentioned below


    . . .
    Subscribe Articles

    Just enter your email below to subscribe and receive weekly updates about the most interesting similar articles.

    You need to accept conditions to receive letters.
    You've Subscribed!

    Share article via

    . . .

    Step 4:

    Create modifier class File.php in app/code/Vendor/Module/Ui/DataProvider/Product/Form/Modifier directory and copy below code

    Step 5:

    At last create template file file.html in /app/code/Vendor/Module/view/adminhtml/web/template/elements directory and write below code

    In this way we can create file type product attribute in magento 2. Thanks.. 🙂

    For complete module please find at

    . . .

    Comments (29)

    Add Your Comment

  • Amit
    Working in Magento 2.3.2
  • Mohit Gohel
    Hi, I have installed this module for this GitHub link for Succesful this
    the module is installed but I face some issue like when the file is upload
    then for this but when I save but can’t save this file in product And can’t
    showing delete option for this module so give me a suggestion for that How can i sorted. Thanks
    • Rani Priya
      Seems you haven’t installed module properly.
      Please execute below commands and then check
      Php bin/magento setup:upgrade
      Php bin/magento setup:di:compile
      Php bin/magento setup:static-content:deploy
      Php bin/magento cache:clean
  • Prashant Marathe
    I have not used it but one question –
    If I have “n” number of attachments – Maybe 4,5,6 (don’t know exactly) with add more functionality then will it work ?
    • Rani Priya
      Could you explain how you have added add more functionality?
  • Sephora Birmingham
    i have added two attributes and this will shows delete checkbox only for first attribute and second attribute is not shown. can you help me for this.
    • Rani Priya
      Do you have added element template for that attribute in modifyMeta method of class app/code/Vendor/Module/Ui/DataProvider/Product/Form/Modifier/File ?
  • Mikoto
    Hi Mate, thanks for the module, working pretty fine. Just one question, how would you display this attribute in front-office then? Like a downloadable file.

    Thank you so much for your work!

  • Back to Top
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again