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?
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
add a comment |
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
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
add a comment |
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
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
magento2 category catalog category-products magento2.2.4
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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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.
Yup, it works. Thanks. +1
– Mohammed Joraid
Jan 22 at 20:30
add a comment |
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.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Yup, it works. Thanks. +1
– Mohammed Joraid
Jan 22 at 20:30
add a comment |
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.
Yup, it works. Thanks. +1
– Mohammed Joraid
Jan 22 at 20:30
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered 24 mins ago
Saad TaimoorSaad Taimoor
694
694
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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