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?

Meta programming: Declare a new struct on the fly

Can I Retrieve Email Addresses from BCC?

Partial sums of primes

Invariance of results when scaling explanatory variables in logistic regression, is there a proof?

Organic chemistry Iodoform Reaction

Is exact Kanji stroke length important?

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

Can a Gentile theist be saved?

Word describing multiple paths to the same abstract outcome

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

What does 사자 in this picture means?

What does the "3am" section means in manpages?

Giant Toughroad SLR 2 for 200 miles in two days, will it make it?

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

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

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

Have I saved too much for retirement so far?

Why is delta-v is the most useful quantity for planning space travel?

Can somebody explain Brexit in a few child-proof sentences?

I2C signal and power over long range (10meter cable)

Is it okay / does it make sense for another player to join a running game of Munchkin?

A workplace installs custom certificates on personal devices, can this be used to decrypt HTTPS traffic?

Why Were Madagascar and New Zealand Discovered So Late?

Proving by induction of n. Is this correct until this point?



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 24 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

            Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

            How to solve knockout JS error in Magento 2 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?(Magento2) knockout.js:3012 Uncaught ReferenceError: Unable to process bindingUnable to process binding Knockout.js magento 2Cannot read property `scopeLabel` of undefined on Product Detail PageCan't get Customer Data on frontend in Magento 2Magento2 Order Summary - unable to process bindingKO templates are not loading in Magento 2.1 applicationgetting knockout js error magento 2Product grid not load -— Unable to process binding Knockout.js magento 2Product form not loaded in magento2Uncaught ReferenceError: Unable to process binding “if: function()return (isShowLegend()) ” magento 2

            Nissan Patrol Зміст Перше покоління — 4W60 (1951-1960) | Друге покоління — 60 series (1960-1980) | Третє покоління (1980–2002) | Четверте покоління — Y60 (1987–1998) | П'яте покоління — Y61 (1997–2013) | Шосте покоління — Y62 (2010- ) | Посилання | Зноски | Навігаційне менюОфіційний український сайтТест-драйв Nissan Patrol 2010 7-го поколінняNissan PatrolКак мы тестировали Nissan Patrol 2016рвиправивши або дописавши її