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

    Add image to a product created by installer in magento2

    Today i am explaining, if you want to created a product in magento2 using installer then you can follow following link:

    Create Product By Installer

    Now, if you want to assign an image to that product, then you can follow the mentioned process:

    Firstly you need to manage your image, i.e. you need to move your file from your module folder to media folder.

    your image file should be at: /app/code/Webkul/Test/view/frontend/web/images/upload.png

    Now add following code in /app/code/Webkul/Test/Setup/InstallSchema.php


    after executing this code your file moved to pub/media/test/upload.png

    Now in InstallData file, in which you are creating your product, add following code:


    After this, your product with an image is created.

    Hope this blog is helps you.

    Thank you.

    . . .

    Comment

    Add Your Comment

    Be the first to comment.

    Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just received your message and our expert will get back to you shortly.
    Send Again
    Close