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?

Why are all the doors on Ferenginar (the Ferengi home world) far shorter than the average Ferengi?

Did US corporations pay demonstrators in the German demonstrations against article 13?

Hostile work environment after whistle-blowing on coworker and our boss. What do I do?

In Star Trek IV, why did the Bounty go back to a time when whales were already rare?

Indicating multiple different modes of speech (fantasy language or telepathy)

Female=gender counterpart?

Pronouncing Homer as in modern Greek

Visiting the UK as unmarried couple

I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?

What will be the benefits of Brexit?

Are Warlocks Arcane or Divine?

Can the harmonic series explain the origin of the major scale?

Resetting two CD4017 counters simultaneously, only one resets

What is the opposite of 'gravitas'?

Lightning Web Component - do I need to track changes for every single input field in a form

Books on the History of math research at European universities

Bob has never been a M before

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

Why are on-board computers allowed to change controls without notifying the pilots?

How to color a zone in Tikz

Can I rely on these GitHub repository files?

Identify a stage play about a VR experience in which participants are encouraged to simulate performing horrific activities

For airliners, what prevents wing strikes on landing in bad weather?

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?













2















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















2















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













2












2








2


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

5711




5711












  • 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 21 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

            Disable / Remove link to Product Items in Cart Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?How can I limit products that can be bought / added to cart?Remove item from cartHide “Add to Cart” button if specific products are already in cart“Prettifying” the custom options in cart pageCreate link in cart sidebar to view all added items After limit reachedLink products together in checkout/cartHow to Get product from cart and add it againHide action-edit on cart page if simple productRemoving Cart items - ObserverRemove wishlist items when added to cart

            Helsingin valtaus Sisällysluettelo Taustaa | Yleistä sotatoimista | Osapuolet | Taistelut Helsingin ympäristössä | Punaisten antautumissuunnitelma | Taistelujen kulku Helsingissä | Valtauksen jälkeen | Tappiot | Muistaminen | Kirjallisuutta | Lähteet | Aiheesta muualla | NavigointivalikkoTeoksen verkkoversioTeoksen verkkoversioGoogle BooksSisällissota Helsingissä päättyi tasan 95 vuotta sittenSaksalaisten ylivoima jyräsi punaisen HelsinginSuomalaiset kuvaavat sotien jälkiä kaupungeissa – katso kuvat ja tarinat tutuilta kulmiltaHelsingin valtaus 90 vuotta sittenSaksalaiset valtasivat HelsinginHyökkäys HelsinkiinHelsingin valtaus 12.–13.4. 1918Saksalaiset käyttivät ihmiskilpiä Helsingin valtauksessa 1918Teoksen verkkoversioTeoksen verkkoversioSaksalaiset hyökkäävät Etelä-SuomeenTaistelut LeppävaarassaSotilaat ja taistelutLeppävaara 1918 huhtikuussa. KapinatarinaHelsingin taistelut 1918Saksalaisten voitonparaati HelsingissäHelsingin valtausta juhlittiinSaksalaisten Helsinki vuonna 1918Helsingin taistelussa kaatuneet valkokaartilaisetHelsinkiin haudatut taisteluissa kaatuneet punaiset12.4.1918 Helsingin valtauksessa saksalaiset apujoukot vapauttavat kaupunginVapaussodan muistomerkkejä Helsingissä ja pääkaupunkiseudullaCrescendo / Vuoden 1918 Kansalaissodan uhrien muistomerkkim

            Adjektiivitarina Tarinan tekeminen | Esimerkki: ennen | Esimerkki: jälkeen | Navigointivalikko