Submit a enquiry

    Back to all posts

    Show sub categories in Magento2

    by James Holloway Partnership Director

    Here is a Magento2 extension that we have used to display sub-categories on a category page in Magento2. This is a common requirement –  to do this we used an extension from online but changed it to suit our needs (a more generic need).

    The extension will now, when used, show the subcategory image, title, and link in a list format. You can change the template output to whatever you require, however, this is a good starting point.

    Download the extension here.

    Change YourCompanyName to your company/package name – this is present in a few places in the code so you will need to do a find/replace all.

    Install the extension and create a static block called something like ‘Sub Categories’.

    Add this code to the static block:

    And save.

    Then, go to the category where you want to show it’s sub-categories (make sure it has some sub-categories, and make sure these have a ‘Thumbnail’ image selected).

    Under ‘Content’ – choose the static block you have just created. Under ‘Display Settings’, select either ‘Static block only’ or ‘Static block and products’ (to show both).

    Once saved this should now work.

    If you want to edit the output template, you can do this here:  app/code/YourCompanyName/Categorylist/view/frontend/templates/category/sub.phtml

    The code is all marked up and should be easy to understand – any probs give me a shout on either telephone (0161 398 0303) or email ([email protected]).