Products
In this section, we will cover the basics of products. We will show you how to fetch products from in a variety of ways.
Overview
There are two main functions to fetch products from Magento 2: productDetails and products. Both are very similar and accept the same arguments. The main difference is in the reponse they return. The productDetails method returns a single product related data, while the products method returns a list of products related data. The first one is optimized to be used on single product pages, while the second one is optimized to be used on product list pages like category pages, search results pages, etc.
References
Method | Description |
---|---|
productDetails | Method to fetch product details |
products | Method to fetch products |
relatedProducts | Method to fetch related products |
upsellProducts | Method to fetch upsell products |
productReview | Method to fetch reviews |