How to Get all products assigned to category by category id Magento 2.

You can retrieve all the products assigned to a specific category by category id in Magento 2.

Used interface:

Get Method from the interface to fetch a list of all the products, public function getAssignedProducts($categoryId);

Get all the assigned product to a specific category by iterate over a loop from the above method,


The output will be Product SKU, Product Position, category id.