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

    Get Magento 2 Version and Edition in Frontend Programatically

    Hello everyone.
    There are several situations where we need to programmatically know the Version and Edition of Magento 2. You can use the below code to get both the version and edition (Community or Enterprise) of Magento.

    First of all, make an instance of the class \Magento\Framework\App\ProductMetadataInterface in the construct as below


    After that, you can use the following codes to print the version and edition of Magento-


    Above lines of code will print the Magento 2 Version and Magento 2 Edition as you can see in the below screenshot-

    I have Used this snippet of code in Controller, but you can use this in Block or Helper files as per your need.

    This is all for now. Hope it will help. 🙂

    . . .

    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