Home » Magento23 June 2015

Magento: Get all products from a category

Here is a quick code to get all products from a particular/specified category in Magento.

First of all, you need to load the category (whose products you want to display) and get it’s ID. You can load a category by it’s ID or if you are in a category page then you can get category information from Magento registry. I have included code to load category in both ways.

You can fetch all enabled or disabled and visible or not visible products. We create ‘not visible’ products while creating configurable type products. In the below code, I have created a filter to fetch only enabled and visible products. You can comment out those filters to fetch disabled and not visible products as well.

Here is the full code:

Hope this helps. Thanks.


Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed