Home » Magento, Magento 21 June 2016

Magento 2: Load Product by ID and SKU

This article shows how to load product by id and sku in Magento 2.

We will be using Magento 2’s Service Layer for this task. Use of Service Layer is highly encouraged by Magento.

Below is a block class of my custom module (Chapagain_HelloWorld). I have injected object of \Magento\Catalog\Model\ProductRepository class in the constructor of my module’s block class.


Now, we load the product by id and sku in template file.

Using Object Manager

Hope this helps. Thanks.

Magento 2

Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed
  • magento

  • SAndeep

    giving me this error: Fatal error: Uncaught exception ‘RuntimeException’ with message ‘ObjectManager isn’t initialized’ in /Volumes/webserver/magento2/vendor/magento/framework/App/ObjectManager.php:31