{"id":3226,"date":"2022-07-07T07:16:10","date_gmt":"2022-07-07T07:16:10","guid":{"rendered":"https:\/\/www.cynoinfotech.com\/?p=3226"},"modified":"2026-04-16T13:32:11","modified_gmt":"2026-04-16T13:32:11","slug":"how-to-load-product-by-id-in-magento-2","status":"publish","type":"post","link":"https:\/\/cynoinfotech.com\/blog\/how-to-load-product-by-id-in-magento-2\/","title":{"rendered":"How to Load Product by ID in Magento 2"},"content":{"rendered":"<p>In this blog, we will explain how to get product data using ID in Magento 2.<\/p>\n<p>Factory method and object manager are the two different ways to lode Product data.<\/p>\n<ul>\n<li><strong>\u00a0Load Product By Id\u00a0 Using Factory Method :<\/strong><\/li>\n<\/ul>\n<pre class=\"lang:default decode:true\">&lt;?php\nnamespace VenderName\\Modulename\\Block;\n \nclass Product extends \\Magento\\Framework\\View\\Element\\Template\n{\n  protected $_productloader;  \n  public function __construct(\n      \\Magento\\Catalog\\Model\\ProductFactory $_productloader\n   ) {\n       $this-&gt;_productloader = $_productloader;\n   }\n   public function getLoadProduct($id)\n   {\n       return $this-&gt;_productloader-&gt;create()-&gt;load($id);\n   }\n}<\/pre>\n<ul>\n<li><strong><strong>Call phtml file :<\/strong><\/strong><\/li>\n<\/ul>\n<pre class=\"lang:default decode:true \">$product_id=22;\n$product=$this-&gt;getLoadProduct(22);\n\/\/echo $product-&gt;getData();\necho $product-&gt;getName();<\/pre>\n<ul>\n<li><strong><strong>\u00a0Load Product By Id Using ObjectManager :<\/strong><\/strong><\/li>\n<\/ul>\n<pre class=\"lang:default decode:true \">$productid = 22;\n$objectManager = \\Magento\\Framework\\App\\ObjectManager::getInstance();\n$product = $objectManager-&gt;get('Magento\\Catalog\\Api\\ProductRepositoryInterface')-&gt;getById($productid);<\/pre>\n<p>We hope the above blog helps you to clearly understand How to Load Products by ID in Magento 2 Programmatically.<\/p>\n<p>If you have any questions let me know in the comment section<\/p>\n<p>Thank You!!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog, we will explain how to get product data using ID in Magento 2. Factory method and object manager are the two different ways to lode Product data. \u00a0Load Product By Id\u00a0 Using Factory Method : &lt;?php namespace VenderName\\Modulename\\Block; class Product extends \\Magento\\Framework\\View\\Element\\Template { protected $_productloader; public function __construct( \\Magento\\Catalog\\Model\\ProductFactory $_productloader ) { [&hellip;]<\/p>\n","protected":false},"author":670,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3226","post","type-post","status-publish","format-standard","hentry","category-magento-blog"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Load Product by ID in Magento 2 - cynoinfotech<\/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:\/\/cynoinfotech.com\/blog\/how-to-load-product-by-id-in-magento-2\/\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/cynoinfotech.com\\\/blog\\\/how-to-load-product-by-id-in-magento-2\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/cynoinfotech.com\\\/blog\\\/how-to-load-product-by-id-in-magento-2\\\/\"},\"author\":{\"name\":\"Arjun Makadiya\",\"@id\":\"https:\\\/\\\/cynoinfotech.com\\\/blog\\\/#\\\/schema\\\/person\\\/f1be8186602d3ebf417cf58baf125f24\"},\"headline\":\"How to Load Product by ID in Magento 2\",\"datePublished\":\"2022-07-07T07:16:10+00:00\",\"dateModified\":\"2026-04-16T13:32:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/cynoinfotech.com\\\/blog\\\/how-to-load-product-by-id-in-magento-2\\\/\"},\"wordCount\":86,\"publisher\":{\"@id\":\"https:\\\/\\\/cynoinfotech.com\\\/blog\\\/#organization\"},\"articleSection\":[\"Magento blog\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/cynoinfotech.com\\\/blog\\\/how-to-load-product-by-id-in-magento-2\\\/\",\"url\":\"https:\\\/\\\/cynoinfotech.com\\\/blog\\\/how-to-load-product-by-id-in-magento-2\\\/\",\"name\":\"How to Load Product by ID in Magento 2 - cynoinfotech\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/cynoinfotech.com\\\/blog\\\/#website\"},\"datePublished\":\"2022-07-07T07:16:10+00:00\",\"dateModified\":\"2026-04-16T13:32:11+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/cynoinfotech.com\\\/blog\\\/how-to-load-product-by-id-in-magento-2\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/cynoinfotech.com\\\/blog\\\/how-to-load-product-by-id-in-magento-2\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/cynoinfotech.com\\\/blog\\\/how-to-load-product-by-id-in-magento-2\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/cynoinfotech.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Load Product by ID in Magento 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/cynoinfotech.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/cynoinfotech.com\\\/blog\\\/\",\"name\":\"cynoinfotech\",\"description\":\"web design &amp; development\",\"publisher\":{\"@id\":\"https:\\\/\\\/cynoinfotech.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/cynoinfotech.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/cynoinfotech.com\\\/blog\\\/#organization\",\"name\":\"Cynoinfotech\",\"url\":\"https:\\\/\\\/cynoinfotech.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/cynoinfotech.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.cynoinfotech.com\\\/wp-content\\\/uploads\\\/2017\\\/11\\\/final-logo-ci.png\",\"contentUrl\":\"https:\\\/\\\/www.cynoinfotech.com\\\/wp-content\\\/uploads\\\/2017\\\/11\\\/final-logo-ci.png\",\"width\":240,\"height\":70,\"caption\":\"Cynoinfotech\"},\"image\":{\"@id\":\"https:\\\/\\\/cynoinfotech.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/cynoinfotech\\\/\",\"https:\\\/\\\/x.com\\\/cynoinfotech\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/cynoinfotech.com\\\/blog\\\/#\\\/schema\\\/person\\\/f1be8186602d3ebf417cf58baf125f24\",\"name\":\"Arjun Makadiya\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d1792fe07de4cbcd8b55a0a55e79e3a67f4df3ab63af6b0738833c83cac0eab3?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d1792fe07de4cbcd8b55a0a55e79e3a67f4df3ab63af6b0738833c83cac0eab3?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d1792fe07de4cbcd8b55a0a55e79e3a67f4df3ab63af6b0738833c83cac0eab3?s=96&d=mm&r=g\",\"caption\":\"Arjun Makadiya\"},\"description\":\"Arjun Makadiya is a Junior Magento Developer at Cynoifotech. He is passionate about technology. Apart from work he likes to play cricket.\",\"url\":\"https:\\\/\\\/cynoinfotech.com\\\/blog\\\/author\\\/arjun-makadiya\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Load Product by ID in Magento 2 - cynoinfotech","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:\/\/cynoinfotech.com\/blog\/how-to-load-product-by-id-in-magento-2\/","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/cynoinfotech.com\/blog\/how-to-load-product-by-id-in-magento-2\/#article","isPartOf":{"@id":"https:\/\/cynoinfotech.com\/blog\/how-to-load-product-by-id-in-magento-2\/"},"author":{"name":"Arjun Makadiya","@id":"https:\/\/cynoinfotech.com\/blog\/#\/schema\/person\/f1be8186602d3ebf417cf58baf125f24"},"headline":"How to Load Product by ID in Magento 2","datePublished":"2022-07-07T07:16:10+00:00","dateModified":"2026-04-16T13:32:11+00:00","mainEntityOfPage":{"@id":"https:\/\/cynoinfotech.com\/blog\/how-to-load-product-by-id-in-magento-2\/"},"wordCount":86,"publisher":{"@id":"https:\/\/cynoinfotech.com\/blog\/#organization"},"articleSection":["Magento blog"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/cynoinfotech.com\/blog\/how-to-load-product-by-id-in-magento-2\/","url":"https:\/\/cynoinfotech.com\/blog\/how-to-load-product-by-id-in-magento-2\/","name":"How to Load Product by ID in Magento 2 - cynoinfotech","isPartOf":{"@id":"https:\/\/cynoinfotech.com\/blog\/#website"},"datePublished":"2022-07-07T07:16:10+00:00","dateModified":"2026-04-16T13:32:11+00:00","breadcrumb":{"@id":"https:\/\/cynoinfotech.com\/blog\/how-to-load-product-by-id-in-magento-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cynoinfotech.com\/blog\/how-to-load-product-by-id-in-magento-2\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/cynoinfotech.com\/blog\/how-to-load-product-by-id-in-magento-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cynoinfotech.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Load Product by ID in Magento 2"}]},{"@type":"WebSite","@id":"https:\/\/cynoinfotech.com\/blog\/#website","url":"https:\/\/cynoinfotech.com\/blog\/","name":"cynoinfotech","description":"web design &amp; development","publisher":{"@id":"https:\/\/cynoinfotech.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cynoinfotech.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/cynoinfotech.com\/blog\/#organization","name":"Cynoinfotech","url":"https:\/\/cynoinfotech.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cynoinfotech.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.cynoinfotech.com\/wp-content\/uploads\/2017\/11\/final-logo-ci.png","contentUrl":"https:\/\/www.cynoinfotech.com\/wp-content\/uploads\/2017\/11\/final-logo-ci.png","width":240,"height":70,"caption":"Cynoinfotech"},"image":{"@id":"https:\/\/cynoinfotech.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/cynoinfotech\/","https:\/\/x.com\/cynoinfotech"]},{"@type":"Person","@id":"https:\/\/cynoinfotech.com\/blog\/#\/schema\/person\/f1be8186602d3ebf417cf58baf125f24","name":"Arjun Makadiya","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d1792fe07de4cbcd8b55a0a55e79e3a67f4df3ab63af6b0738833c83cac0eab3?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d1792fe07de4cbcd8b55a0a55e79e3a67f4df3ab63af6b0738833c83cac0eab3?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d1792fe07de4cbcd8b55a0a55e79e3a67f4df3ab63af6b0738833c83cac0eab3?s=96&d=mm&r=g","caption":"Arjun Makadiya"},"description":"Arjun Makadiya is a Junior Magento Developer at Cynoifotech. He is passionate about technology. Apart from work he likes to play cricket.","url":"https:\/\/cynoinfotech.com\/blog\/author\/arjun-makadiya\/"}]}},"_links":{"self":[{"href":"https:\/\/cynoinfotech.com\/blog\/wp-json\/wp\/v2\/posts\/3226","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cynoinfotech.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cynoinfotech.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cynoinfotech.com\/blog\/wp-json\/wp\/v2\/users\/670"}],"replies":[{"embeddable":true,"href":"https:\/\/cynoinfotech.com\/blog\/wp-json\/wp\/v2\/comments?post=3226"}],"version-history":[{"count":7,"href":"https:\/\/cynoinfotech.com\/blog\/wp-json\/wp\/v2\/posts\/3226\/revisions"}],"predecessor-version":[{"id":3261,"href":"https:\/\/cynoinfotech.com\/blog\/wp-json\/wp\/v2\/posts\/3226\/revisions\/3261"}],"wp:attachment":[{"href":"https:\/\/cynoinfotech.com\/blog\/wp-json\/wp\/v2\/media?parent=3226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cynoinfotech.com\/blog\/wp-json\/wp\/v2\/categories?post=3226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cynoinfotech.com\/blog\/wp-json\/wp\/v2\/tags?post=3226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}