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