{"id":114342,"date":"2018-02-28T11:06:53","date_gmt":"2018-02-28T11:06:53","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=114342"},"modified":"2018-02-28T11:06:53","modified_gmt":"2018-02-28T11:06:53","slug":"get-magento-2-version-edition-frontend-programatically","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/","title":{"rendered":"Get Magento 2 Version and Edition in Frontend Programatically"},"content":{"rendered":"<p>Hello everyone.<br \/>\nThere 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.<\/p>\n<p>First of all, make an instance of the class \\Magento\\Framework\\App\\ProductMetadataInterface in the construct as below<\/p>\n<pre class=\"brush:php\"> public function __construct(\r\n        ...\r\n        \\Magento\\Framework\\App\\ProductMetadataInterface $productMetadata,\r\n        ...\r\n    ) {\r\n        ...\r\n        $this-&gt;_productMetadata = $productMetadata;\r\n        ...\r\n    }\r\n<\/pre>\n<p>After that, you can use the following codes to print the version and edition of Magento-<\/p>\n<pre class=\"brush:php\">public function getMagentoInformation() {\r\n    echo \"Magento Version =&gt; \".$this-&gt;_productMetadata-&gt;getVersion();\r\n    echo \"Magento Edition =&gt; \".$this-&gt;_productMetadata-&gt;getEdition();\r\n}<\/pre>\n<p>Above lines of code will print the Magento 2 Version and Magento 2 Edition as you can see in the below screenshot-<\/p>\n<p><img decoding=\"async\" class=\"size-full wp-image-114346\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/Magento-Version-And-Edition.png\" alt=\"Magento 2 Version and Edition\" width=\"329\" height=\"213\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/Magento-Version-And-Edition.png 329w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/Magento-Version-And-Edition-250x162.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/Magento-Version-And-Edition-300x194.png 300w\" sizes=\"(max-width: 329px) 100vw, 329px\" loading=\"lazy\" \/><\/p>\n<p>I have Used this snippet of code in Controller, but you can use this in Block or Helper files as per your need.<\/p>\n<p>This is all for now. Hope it will help. \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 public function __construct( <a href=\"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":167,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[302],"tags":[6253,6252,2070],"class_list":["post-114342","post","type-post","status-publish","format-standard","hentry","category-magento2","tag-magento-2-edition","tag-magento-2-version","tag-magento2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Get Magento 2 Version and Edition in Frontend Programatically - Webkul Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Get Magento 2 Version and Edition in Frontend Programatically - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"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 MagentoFrameworkAppProductMetadataInterface in the construct as below public function __construct( [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-02-28T11:06:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/02\/Magento-Version-And-Edition.png\" \/>\n<meta name=\"author\" content=\"Hemant Jain\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Hemant Jain\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/\"},\"author\":{\"name\":\"Hemant Jain\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/a824ac6c5c14d32569263100b85f47c6\"},\"headline\":\"Get Magento 2 Version and Edition in Frontend Programatically\",\"datePublished\":\"2018-02-28T11:06:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/\"},\"wordCount\":130,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/02\/Magento-Version-And-Edition.png\",\"keywords\":[\"Magento 2 Edition\",\"Magento 2 Version\",\"Magento2\"],\"articleSection\":[\"Magento2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/\",\"url\":\"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/\",\"name\":\"Get Magento 2 Version and Edition in Frontend Programatically - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/02\/Magento-Version-And-Edition.png\",\"datePublished\":\"2018-02-28T11:06:53+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/Magento-Version-And-Edition.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/Magento-Version-And-Edition.png\",\"width\":329,\"height\":213,\"caption\":\"Magento 2 version and Edition\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Get Magento 2 Version and Edition in Frontend Programatically\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/a824ac6c5c14d32569263100b85f47c6\",\"name\":\"Hemant Jain\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/184358b1c25c580a3e32952605156294dedfff2b8b75bdb2a719c8e6a5d318b6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/184358b1c25c580a3e32952605156294dedfff2b8b75bdb2a719c8e6a5d318b6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Hemant Jain\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/hemant-jain591\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Get Magento 2 Version and Edition in Frontend Programatically - Webkul Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/","og_locale":"en_US","og_type":"article","og_title":"Get Magento 2 Version and Edition in Frontend Programatically - Webkul Blog","og_description":"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 MagentoFrameworkAppProductMetadataInterface in the construct as below public function __construct( [...]","og_url":"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2018-02-28T11:06:53+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/02\/Magento-Version-And-Edition.png","type":"","width":"","height":""}],"author":"Hemant Jain","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Hemant Jain","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/"},"author":{"name":"Hemant Jain","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/a824ac6c5c14d32569263100b85f47c6"},"headline":"Get Magento 2 Version and Edition in Frontend Programatically","datePublished":"2018-02-28T11:06:53+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/"},"wordCount":130,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/02\/Magento-Version-And-Edition.png","keywords":["Magento 2 Edition","Magento 2 Version","Magento2"],"articleSection":["Magento2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/","url":"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/","name":"Get Magento 2 Version and Edition in Frontend Programatically - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/02\/Magento-Version-And-Edition.png","datePublished":"2018-02-28T11:06:53+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/Magento-Version-And-Edition.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/Magento-Version-And-Edition.png","width":329,"height":213,"caption":"Magento 2 version and Edition"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/get-magento-2-version-edition-frontend-programatically\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Get Magento 2 Version and Edition in Frontend Programatically"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/a824ac6c5c14d32569263100b85f47c6","name":"Hemant Jain","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/184358b1c25c580a3e32952605156294dedfff2b8b75bdb2a719c8e6a5d318b6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/184358b1c25c580a3e32952605156294dedfff2b8b75bdb2a719c8e6a5d318b6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Hemant Jain"},"url":"https:\/\/webkul.com\/blog\/author\/hemant-jain591\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/114342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/167"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=114342"}],"version-history":[{"count":3,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/114342\/revisions"}],"predecessor-version":[{"id":114350,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/114342\/revisions\/114350"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=114342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=114342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=114342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}