Magento 2 Different Ways to Load Products

How do you load product by product ID in Magento2?

Using Repository to Load Products – Recommanded

Using Factroy to Load Products

The reason to use ProductRepository’s instead of a ProductFatory’s to load the product is because the former is of a higher level than the latter.

SO, you should use the API layer whenever possible, because:

  • Api/Data layer is used in the Web Api, as well
  • models can – and probably will – be refactored at some point; Api/Data/Product will not.
  • To get a product in your classes, you need to inject either a concrete factory (ProductFactory) or an interface (ProductRepository). I don’t think you want your module to rely on anything but an interface. Hence I disagree with this type of injection.

Using Collection to Load Products

If you need to load multiple products, you should use prodcut collections.

Using Product Mode to Load Products – Deprecated