Magento2: Show subcategory as a grid with imagesPosition Static Block under Category GridShow subcategories within the catalogueGet Categories and Its Sub CategoriesShow category with images in homepage Magento2Magento 1.9.2.4 sub-category listing not workingURL issue with categoriescategory page with static block not listing productsHow to use category image in detail page?Magento2: List the all categories and sub categories in home page left sidebarHow can i do copy of my selected sku products to other category in same root category using CSV?

Simple image editor tool to draw a simple box/rectangle in an existing image

The most efficient algorithm to find all possible integer pairs which sum to a given integer

How do I rename a LINUX host without needing to reboot for the rename to take effect?

Have I saved too much for retirement so far?

Adding empty element to declared container without declaring type of element

How can a jailer prevent the Forge Cleric's Artisan's Blessing from being used?

Are taller landing gear bad for aircraft, particulary large airliners?

Would it be legal for a US State to ban exports of a natural resource?

How can I raise concerns with a new DM about XP splitting?

Meta programming: Declare a new struct on the fly

Organic chemistry Iodoform Reaction

How do I repair my stair bannister?

How to color a zone in Tikz

Is there a problem with hiding "forgot password" until it's needed?

Installing PowerShell on 32-bit Kali OS fails

Greatest common substring

Why does this part of the Space Shuttle launch pad seem to be floating in air?

Java - What do constructor type arguments mean when placed *before* the type?

No idea how to draw this using tikz

Can I use my Chinese passport to enter China after I acquired another citizenship?

What do you call the infoboxes with text and sometimes images on the side of a page we find in textbooks?

Is there enough fresh water in the world to eradicate the drinking water crisis?

Partial sums of primes

My boss asked me to take a one-day class, then signs it up as a day off



Magento2: Show subcategory as a grid with images


Position Static Block under Category GridShow subcategories within the catalogueGet Categories and Its Sub CategoriesShow category with images in homepage Magento2Magento 1.9.2.4 sub-category listing not workingURL issue with categoriescategory page with static block not listing productsHow to use category image in detail page?Magento2: List the all categories and sub categories in home page left sidebarHow can i do copy of my selected sku products to other category in same root category using CSV?













3















I need to display all the sub categories under every category as a grid in relevant pages with linked images. Is there a way to do it ? I am using magento 2.2.4










share|improve this question






















  • What about the products of that category?

    – Sukumar Gorai
    Jul 17 '18 at 12:46











  • @SukumarGorai When clicking on the sub category image, I need to redirect it to the relevant products page

    – SMash
    Jul 18 '18 at 3:33











  • So you mean if any of the category have subcategories then need to show subcategories page and if no subcategories then redirect to relevant listing page. Right?

    – Sukumar Gorai
    Jul 18 '18 at 5:46











  • @SukumarGorai Yes that is how it needs

    – SMash
    Jul 18 '18 at 6:07















3















I need to display all the sub categories under every category as a grid in relevant pages with linked images. Is there a way to do it ? I am using magento 2.2.4










share|improve this question






















  • What about the products of that category?

    – Sukumar Gorai
    Jul 17 '18 at 12:46











  • @SukumarGorai When clicking on the sub category image, I need to redirect it to the relevant products page

    – SMash
    Jul 18 '18 at 3:33











  • So you mean if any of the category have subcategories then need to show subcategories page and if no subcategories then redirect to relevant listing page. Right?

    – Sukumar Gorai
    Jul 18 '18 at 5:46











  • @SukumarGorai Yes that is how it needs

    – SMash
    Jul 18 '18 at 6:07













3












3








3


1






I need to display all the sub categories under every category as a grid in relevant pages with linked images. Is there a way to do it ? I am using magento 2.2.4










share|improve this question














I need to display all the sub categories under every category as a grid in relevant pages with linked images. Is there a way to do it ? I am using magento 2.2.4







magento2 category catalog category-products magento2.2.4






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jul 17 '18 at 12:33









SMashSMash

6211




6211












  • What about the products of that category?

    – Sukumar Gorai
    Jul 17 '18 at 12:46











  • @SukumarGorai When clicking on the sub category image, I need to redirect it to the relevant products page

    – SMash
    Jul 18 '18 at 3:33











  • So you mean if any of the category have subcategories then need to show subcategories page and if no subcategories then redirect to relevant listing page. Right?

    – Sukumar Gorai
    Jul 18 '18 at 5:46











  • @SukumarGorai Yes that is how it needs

    – SMash
    Jul 18 '18 at 6:07

















  • What about the products of that category?

    – Sukumar Gorai
    Jul 17 '18 at 12:46











  • @SukumarGorai When clicking on the sub category image, I need to redirect it to the relevant products page

    – SMash
    Jul 18 '18 at 3:33











  • So you mean if any of the category have subcategories then need to show subcategories page and if no subcategories then redirect to relevant listing page. Right?

    – Sukumar Gorai
    Jul 18 '18 at 5:46











  • @SukumarGorai Yes that is how it needs

    – SMash
    Jul 18 '18 at 6:07
















What about the products of that category?

– Sukumar Gorai
Jul 17 '18 at 12:46





What about the products of that category?

– Sukumar Gorai
Jul 17 '18 at 12:46













@SukumarGorai When clicking on the sub category image, I need to redirect it to the relevant products page

– SMash
Jul 18 '18 at 3:33





@SukumarGorai When clicking on the sub category image, I need to redirect it to the relevant products page

– SMash
Jul 18 '18 at 3:33













So you mean if any of the category have subcategories then need to show subcategories page and if no subcategories then redirect to relevant listing page. Right?

– Sukumar Gorai
Jul 18 '18 at 5:46





So you mean if any of the category have subcategories then need to show subcategories page and if no subcategories then redirect to relevant listing page. Right?

– Sukumar Gorai
Jul 18 '18 at 5:46













@SukumarGorai Yes that is how it needs

– SMash
Jul 18 '18 at 6:07





@SukumarGorai Yes that is how it needs

– SMash
Jul 18 '18 at 6:07










2 Answers
2






active

oldest

votes


















2














You need to copy the below file:




vendor/magento/module-catalog/view/frontend/templates/category/products.phtml




to your theme like below:




app/design/frontend/[Vendor]/[theme]/Magento_Catalog/templates/category/products.phtml




And add the below code to product.phtml:



<?php $category = $block->getCurrentCategory(); ?>
<?php $subcategories = $category->getChildrenCategories(); ?>
<?php $_helper = $this->helper('MagentoCatalogHelperOutput'); ?>
<?php $objectManager = MagentoFrameworkAppObjectManager::getInstance(); ?>
<?php if(count($subcategories) > 0): ?>
<div class="products wrapper grid products-grid">
<ol class="products list items product-items">
<?php foreach($category->getChildrenCategories() as $subcategory): ?>
<?php $subcategory = $objectManager->create('MagentoCatalogModelCategory')->load($subcategory->getId()); ?>
<li class="item product product-item">
<div class="product-item-info">
<?php if ($_imgUrl = $subcategory->getImageUrl()): ?>
<a href="<?= $subcategory->getUrl() ?>" class="product photo product-item-photo">
<span class="product-image-container">
<?php $_imgHtml = '<img src="' . $_imgUrl . '" />'; ?>
<?php echo $_imgHtml = $_helper->categoryAttribute($subcategory, $_imgHtml, 'image'); ?>
</span>
</a>
<?php endif; ?>
<div class="product details product-item-details">
<strong class="product name product-item-name">
<a class="product-item-link" href="<?= $subcategory->getUrl() ?>"><?= $subcategory->getName() ?></a>
</strong>
</div>
</div>
</li>
<?php endforeach; ?>
</ol>
</div>
<?php else: ?>
<?php if (!$block->isContentMode() || $block->isMixedMode()): ?>
<?= $block->getProductListHtml() ?>
<?php endif; ?>
<?php endif; ?>


You need to manage the css according to your requirement and also need to hide the layered navigation through css or update it to 1 column according to your requirement.






share|improve this answer























  • Yup, it works. Thanks. +1

    – Mohammed Joraid
    Jan 22 at 20:30



















0














If you are still looking for a solution to show Subcategories on parent category page. Have a look at Advanced Subcategory Grid module on Magento2 Marketplace that can be used to show subcategories on category pages, its highly customizable and also supports configurable color swatches as-well.






share|improve this answer






















    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "479"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f234838%2fmagento2-show-subcategory-as-a-grid-with-images%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    You need to copy the below file:




    vendor/magento/module-catalog/view/frontend/templates/category/products.phtml




    to your theme like below:




    app/design/frontend/[Vendor]/[theme]/Magento_Catalog/templates/category/products.phtml




    And add the below code to product.phtml:



    <?php $category = $block->getCurrentCategory(); ?>
    <?php $subcategories = $category->getChildrenCategories(); ?>
    <?php $_helper = $this->helper('MagentoCatalogHelperOutput'); ?>
    <?php $objectManager = MagentoFrameworkAppObjectManager::getInstance(); ?>
    <?php if(count($subcategories) > 0): ?>
    <div class="products wrapper grid products-grid">
    <ol class="products list items product-items">
    <?php foreach($category->getChildrenCategories() as $subcategory): ?>
    <?php $subcategory = $objectManager->create('MagentoCatalogModelCategory')->load($subcategory->getId()); ?>
    <li class="item product product-item">
    <div class="product-item-info">
    <?php if ($_imgUrl = $subcategory->getImageUrl()): ?>
    <a href="<?= $subcategory->getUrl() ?>" class="product photo product-item-photo">
    <span class="product-image-container">
    <?php $_imgHtml = '<img src="' . $_imgUrl . '" />'; ?>
    <?php echo $_imgHtml = $_helper->categoryAttribute($subcategory, $_imgHtml, 'image'); ?>
    </span>
    </a>
    <?php endif; ?>
    <div class="product details product-item-details">
    <strong class="product name product-item-name">
    <a class="product-item-link" href="<?= $subcategory->getUrl() ?>"><?= $subcategory->getName() ?></a>
    </strong>
    </div>
    </div>
    </li>
    <?php endforeach; ?>
    </ol>
    </div>
    <?php else: ?>
    <?php if (!$block->isContentMode() || $block->isMixedMode()): ?>
    <?= $block->getProductListHtml() ?>
    <?php endif; ?>
    <?php endif; ?>


    You need to manage the css according to your requirement and also need to hide the layered navigation through css or update it to 1 column according to your requirement.






    share|improve this answer























    • Yup, it works. Thanks. +1

      – Mohammed Joraid
      Jan 22 at 20:30
















    2














    You need to copy the below file:




    vendor/magento/module-catalog/view/frontend/templates/category/products.phtml




    to your theme like below:




    app/design/frontend/[Vendor]/[theme]/Magento_Catalog/templates/category/products.phtml




    And add the below code to product.phtml:



    <?php $category = $block->getCurrentCategory(); ?>
    <?php $subcategories = $category->getChildrenCategories(); ?>
    <?php $_helper = $this->helper('MagentoCatalogHelperOutput'); ?>
    <?php $objectManager = MagentoFrameworkAppObjectManager::getInstance(); ?>
    <?php if(count($subcategories) > 0): ?>
    <div class="products wrapper grid products-grid">
    <ol class="products list items product-items">
    <?php foreach($category->getChildrenCategories() as $subcategory): ?>
    <?php $subcategory = $objectManager->create('MagentoCatalogModelCategory')->load($subcategory->getId()); ?>
    <li class="item product product-item">
    <div class="product-item-info">
    <?php if ($_imgUrl = $subcategory->getImageUrl()): ?>
    <a href="<?= $subcategory->getUrl() ?>" class="product photo product-item-photo">
    <span class="product-image-container">
    <?php $_imgHtml = '<img src="' . $_imgUrl . '" />'; ?>
    <?php echo $_imgHtml = $_helper->categoryAttribute($subcategory, $_imgHtml, 'image'); ?>
    </span>
    </a>
    <?php endif; ?>
    <div class="product details product-item-details">
    <strong class="product name product-item-name">
    <a class="product-item-link" href="<?= $subcategory->getUrl() ?>"><?= $subcategory->getName() ?></a>
    </strong>
    </div>
    </div>
    </li>
    <?php endforeach; ?>
    </ol>
    </div>
    <?php else: ?>
    <?php if (!$block->isContentMode() || $block->isMixedMode()): ?>
    <?= $block->getProductListHtml() ?>
    <?php endif; ?>
    <?php endif; ?>


    You need to manage the css according to your requirement and also need to hide the layered navigation through css or update it to 1 column according to your requirement.






    share|improve this answer























    • Yup, it works. Thanks. +1

      – Mohammed Joraid
      Jan 22 at 20:30














    2












    2








    2







    You need to copy the below file:




    vendor/magento/module-catalog/view/frontend/templates/category/products.phtml




    to your theme like below:




    app/design/frontend/[Vendor]/[theme]/Magento_Catalog/templates/category/products.phtml




    And add the below code to product.phtml:



    <?php $category = $block->getCurrentCategory(); ?>
    <?php $subcategories = $category->getChildrenCategories(); ?>
    <?php $_helper = $this->helper('MagentoCatalogHelperOutput'); ?>
    <?php $objectManager = MagentoFrameworkAppObjectManager::getInstance(); ?>
    <?php if(count($subcategories) > 0): ?>
    <div class="products wrapper grid products-grid">
    <ol class="products list items product-items">
    <?php foreach($category->getChildrenCategories() as $subcategory): ?>
    <?php $subcategory = $objectManager->create('MagentoCatalogModelCategory')->load($subcategory->getId()); ?>
    <li class="item product product-item">
    <div class="product-item-info">
    <?php if ($_imgUrl = $subcategory->getImageUrl()): ?>
    <a href="<?= $subcategory->getUrl() ?>" class="product photo product-item-photo">
    <span class="product-image-container">
    <?php $_imgHtml = '<img src="' . $_imgUrl . '" />'; ?>
    <?php echo $_imgHtml = $_helper->categoryAttribute($subcategory, $_imgHtml, 'image'); ?>
    </span>
    </a>
    <?php endif; ?>
    <div class="product details product-item-details">
    <strong class="product name product-item-name">
    <a class="product-item-link" href="<?= $subcategory->getUrl() ?>"><?= $subcategory->getName() ?></a>
    </strong>
    </div>
    </div>
    </li>
    <?php endforeach; ?>
    </ol>
    </div>
    <?php else: ?>
    <?php if (!$block->isContentMode() || $block->isMixedMode()): ?>
    <?= $block->getProductListHtml() ?>
    <?php endif; ?>
    <?php endif; ?>


    You need to manage the css according to your requirement and also need to hide the layered navigation through css or update it to 1 column according to your requirement.






    share|improve this answer













    You need to copy the below file:




    vendor/magento/module-catalog/view/frontend/templates/category/products.phtml




    to your theme like below:




    app/design/frontend/[Vendor]/[theme]/Magento_Catalog/templates/category/products.phtml




    And add the below code to product.phtml:



    <?php $category = $block->getCurrentCategory(); ?>
    <?php $subcategories = $category->getChildrenCategories(); ?>
    <?php $_helper = $this->helper('MagentoCatalogHelperOutput'); ?>
    <?php $objectManager = MagentoFrameworkAppObjectManager::getInstance(); ?>
    <?php if(count($subcategories) > 0): ?>
    <div class="products wrapper grid products-grid">
    <ol class="products list items product-items">
    <?php foreach($category->getChildrenCategories() as $subcategory): ?>
    <?php $subcategory = $objectManager->create('MagentoCatalogModelCategory')->load($subcategory->getId()); ?>
    <li class="item product product-item">
    <div class="product-item-info">
    <?php if ($_imgUrl = $subcategory->getImageUrl()): ?>
    <a href="<?= $subcategory->getUrl() ?>" class="product photo product-item-photo">
    <span class="product-image-container">
    <?php $_imgHtml = '<img src="' . $_imgUrl . '" />'; ?>
    <?php echo $_imgHtml = $_helper->categoryAttribute($subcategory, $_imgHtml, 'image'); ?>
    </span>
    </a>
    <?php endif; ?>
    <div class="product details product-item-details">
    <strong class="product name product-item-name">
    <a class="product-item-link" href="<?= $subcategory->getUrl() ?>"><?= $subcategory->getName() ?></a>
    </strong>
    </div>
    </div>
    </li>
    <?php endforeach; ?>
    </ol>
    </div>
    <?php else: ?>
    <?php if (!$block->isContentMode() || $block->isMixedMode()): ?>
    <?= $block->getProductListHtml() ?>
    <?php endif; ?>
    <?php endif; ?>


    You need to manage the css according to your requirement and also need to hide the layered navigation through css or update it to 1 column according to your requirement.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jul 18 '18 at 7:11









    Sukumar GoraiSukumar Gorai

    6,8903729




    6,8903729












    • Yup, it works. Thanks. +1

      – Mohammed Joraid
      Jan 22 at 20:30


















    • Yup, it works. Thanks. +1

      – Mohammed Joraid
      Jan 22 at 20:30

















    Yup, it works. Thanks. +1

    – Mohammed Joraid
    Jan 22 at 20:30






    Yup, it works. Thanks. +1

    – Mohammed Joraid
    Jan 22 at 20:30














    0














    If you are still looking for a solution to show Subcategories on parent category page. Have a look at Advanced Subcategory Grid module on Magento2 Marketplace that can be used to show subcategories on category pages, its highly customizable and also supports configurable color swatches as-well.






    share|improve this answer



























      0














      If you are still looking for a solution to show Subcategories on parent category page. Have a look at Advanced Subcategory Grid module on Magento2 Marketplace that can be used to show subcategories on category pages, its highly customizable and also supports configurable color swatches as-well.






      share|improve this answer

























        0












        0








        0







        If you are still looking for a solution to show Subcategories on parent category page. Have a look at Advanced Subcategory Grid module on Magento2 Marketplace that can be used to show subcategories on category pages, its highly customizable and also supports configurable color swatches as-well.






        share|improve this answer













        If you are still looking for a solution to show Subcategories on parent category page. Have a look at Advanced Subcategory Grid module on Magento2 Marketplace that can be used to show subcategories on category pages, its highly customizable and also supports configurable color swatches as-well.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 33 mins ago









        Saad TaimoorSaad Taimoor

        694




        694



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f234838%2fmagento2-show-subcategory-as-a-grid-with-images%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Nidaros erkebispedøme

            Birsay

            Was Woodrow Wilson really a Liberal?Was World War I a war of liberals against authoritarians?Founding Fathers...