Home » Magento, Magento 227 May 2016

Magento 2: Get list of all Categories & Store Categories

This article shows how we can get list of all categories and all category of current store in Magento 2.

Below is a block class of my custom module (Chapagain_HelloWorld). I have injected object of \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory and \Magento\Catalog\Helper\Category classes in the constructor of my module’s block class.

app/code/Chapagain/HelloWorld/Block/HelloWorld.php

Now, we fetch and print the category collection.

Hope this helps. Thanks.

php magento mukesh chapagain

Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed
  • Gael COAT

    Thanks Mukeh, very helpful !