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

    . . .
    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

    . . .

    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.

    . . .


    Add Your Comment

    Be the first to comment.

    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