Displaying subcategories instead of products 2.1Get subcategories of parent category when FLAT categories...
Why are on-board computers allowed to change controls without notifying the pilots?
Why is delta-v is the most useful quantity for planning space travel?
Why Were Madagascar and New Zealand Discovered So Late?
Who must act to prevent Brexit on March 29th?
Identify a stage play about a VR experience in which participants are encouraged to simulate performing horrific activities
Should a half Jewish man be discouraged from marrying a Jewess?
Is there a problem with hiding "forgot password" until it's needed?
For airliners, what prevents wing strikes on landing in bad weather?
What is the opposite of 'gravitas'?
How do I rename a LINUX host without needing to reboot for the rename to take effect?
Can I create an upright 7-foot × 5-foot wall with the Minor Illusion spell?
Is there an Impartial Brexit Deal comparison site?
I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?
No idea how to draw this using tikz
How to deal with or prevent idle in the test team?
What do you call the infoboxes with text and sometimes images on the side of a page we find in textbooks?
Is it okay / does it make sense for another player to join a running game of Munchkin?
Word describing multiple paths to the same abstract outcome
Simple recursive Sudoku solver
Meta programming: Declare a new struct on the fly
Have I saved too much for retirement so far?
Can a Bard use an arcane focus?
How do I repair my stair bannister?
What will be the benefits of Brexit?
Displaying subcategories instead of products 2.1
Get subcategories of parent category when FLAT categories enabledSearch by multiple Tags onlyNavigation Pre-Loads on Certain PagesChange Magento2 Home Page TextBatch creating subcategoriesMagento 2 - Show subcategories (and products) on category pageMagento 2.1 : getLoadedProductCollection() always returns all productsMagento 2 - Display subcategories above product listingMagento 2: Left Category Sidebar from Sebwite (copy of question)Why use a theme when you have modules?
I am fairly new to Magento, and am having trouble figuring out what I need to add to do this. I have looked all over for this, but can not find a solution that shows how to do this for magento 2. I am looking for how to create a module that displays all of the subcategories of the category clicked. If there are no more subcategories, then I want to display the products for that category.
I have tried making blocks in the admin panel, and attaching these blocks to the product category. I would really like to just create a module that does this for me though.
magento2 navigation
add a comment |
I am fairly new to Magento, and am having trouble figuring out what I need to add to do this. I have looked all over for this, but can not find a solution that shows how to do this for magento 2. I am looking for how to create a module that displays all of the subcategories of the category clicked. If there are no more subcategories, then I want to display the products for that category.
I have tried making blocks in the admin panel, and attaching these blocks to the product category. I would really like to just create a module that does this for me though.
magento2 navigation
add a comment |
I am fairly new to Magento, and am having trouble figuring out what I need to add to do this. I have looked all over for this, but can not find a solution that shows how to do this for magento 2. I am looking for how to create a module that displays all of the subcategories of the category clicked. If there are no more subcategories, then I want to display the products for that category.
I have tried making blocks in the admin panel, and attaching these blocks to the product category. I would really like to just create a module that does this for me though.
magento2 navigation
I am fairly new to Magento, and am having trouble figuring out what I need to add to do this. I have looked all over for this, but can not find a solution that shows how to do this for magento 2. I am looking for how to create a module that displays all of the subcategories of the category clicked. If there are no more subcategories, then I want to display the products for that category.
I have tried making blocks in the admin panel, and attaching these blocks to the product category. I would really like to just create a module that does this for me though.
magento2 navigation
magento2 navigation
edited Jan 8 at 9:21
Teja Bhagavan Kollepara
3,00641949
3,00641949
asked Oct 17 '16 at 15:18
tadmintadmin
1112
1112
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
You need to customized the category in the theme folder use the
following file structure and update the following code
/app/design/frontend/<vendor>/theme/Magento_Catalog/templates/category
products.phtml
<?php
// call current category and sub category
$categoryHelper_sub = $this->helper('MagentoCatalogHelperCategory');
$_category = $block->getCurrentCategory();
$objectManager_sub = $objectManager =
MagentoFrameworkAppObjectManager::getInstance();
$imagehelper = $objectManager->create('MagentoCatalogHelperImage');
$category = $objectManager_sub->get('MagentoCatalogModelCategory');
$categories_sub =
$category->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('is_active',
1)->addIdFilter($_category->getChildren())->setOrder('position', 'ASC');?>
<?php if(!empty($categories_sub->getData())){ ?>
<div class="page-products">
<div class="products wrapper grid products-grid">
<div class="col-xs-12 abt_head caps">
<h2><?php echo $_category->getName(); ?></h2>
<p><?php echo $_category->getDescription(); ?></p>
<div class="current-image">
<img src="<?php echo $_category->getImageUrl()?>" >
</div>
</div>
<?php foreach($categories_sub as $category_sub): ?>
<?php $category_sub->getParentId();
$categoryobj =
$objectManager->create('MagentoCatalogModelCategoryFactory');
$category =
$objectManager->get('MagentoFrameworkRegistry')->registry('current_category');//get
current category
$category_sub->getChildren();?>
<div class='submenu'>
<a href="<?php echo
$categoryHelper_sub->getCategoryUrl($category_sub);?>">
<div class='submenu-img'> <img src="<?php echo
$category_sub->getImageUrl()?>" alt="<?php echo
$category_sub->getName()?>"></img>
</div>
<?php //echo $category_sub->getName()?></a>
</div>
<?php endforeach; ?>
</div>
<?php } ?>
add a comment |
I have create small module for display sub category please check this link.
https://github.com/pratikmage/magento2-subcategory
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%2f141236%2fdisplaying-subcategories-instead-of-products-2-1%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to customized the category in the theme folder use the
following file structure and update the following code
/app/design/frontend/<vendor>/theme/Magento_Catalog/templates/category
products.phtml
<?php
// call current category and sub category
$categoryHelper_sub = $this->helper('MagentoCatalogHelperCategory');
$_category = $block->getCurrentCategory();
$objectManager_sub = $objectManager =
MagentoFrameworkAppObjectManager::getInstance();
$imagehelper = $objectManager->create('MagentoCatalogHelperImage');
$category = $objectManager_sub->get('MagentoCatalogModelCategory');
$categories_sub =
$category->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('is_active',
1)->addIdFilter($_category->getChildren())->setOrder('position', 'ASC');?>
<?php if(!empty($categories_sub->getData())){ ?>
<div class="page-products">
<div class="products wrapper grid products-grid">
<div class="col-xs-12 abt_head caps">
<h2><?php echo $_category->getName(); ?></h2>
<p><?php echo $_category->getDescription(); ?></p>
<div class="current-image">
<img src="<?php echo $_category->getImageUrl()?>" >
</div>
</div>
<?php foreach($categories_sub as $category_sub): ?>
<?php $category_sub->getParentId();
$categoryobj =
$objectManager->create('MagentoCatalogModelCategoryFactory');
$category =
$objectManager->get('MagentoFrameworkRegistry')->registry('current_category');//get
current category
$category_sub->getChildren();?>
<div class='submenu'>
<a href="<?php echo
$categoryHelper_sub->getCategoryUrl($category_sub);?>">
<div class='submenu-img'> <img src="<?php echo
$category_sub->getImageUrl()?>" alt="<?php echo
$category_sub->getName()?>"></img>
</div>
<?php //echo $category_sub->getName()?></a>
</div>
<?php endforeach; ?>
</div>
<?php } ?>
add a comment |
You need to customized the category in the theme folder use the
following file structure and update the following code
/app/design/frontend/<vendor>/theme/Magento_Catalog/templates/category
products.phtml
<?php
// call current category and sub category
$categoryHelper_sub = $this->helper('MagentoCatalogHelperCategory');
$_category = $block->getCurrentCategory();
$objectManager_sub = $objectManager =
MagentoFrameworkAppObjectManager::getInstance();
$imagehelper = $objectManager->create('MagentoCatalogHelperImage');
$category = $objectManager_sub->get('MagentoCatalogModelCategory');
$categories_sub =
$category->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('is_active',
1)->addIdFilter($_category->getChildren())->setOrder('position', 'ASC');?>
<?php if(!empty($categories_sub->getData())){ ?>
<div class="page-products">
<div class="products wrapper grid products-grid">
<div class="col-xs-12 abt_head caps">
<h2><?php echo $_category->getName(); ?></h2>
<p><?php echo $_category->getDescription(); ?></p>
<div class="current-image">
<img src="<?php echo $_category->getImageUrl()?>" >
</div>
</div>
<?php foreach($categories_sub as $category_sub): ?>
<?php $category_sub->getParentId();
$categoryobj =
$objectManager->create('MagentoCatalogModelCategoryFactory');
$category =
$objectManager->get('MagentoFrameworkRegistry')->registry('current_category');//get
current category
$category_sub->getChildren();?>
<div class='submenu'>
<a href="<?php echo
$categoryHelper_sub->getCategoryUrl($category_sub);?>">
<div class='submenu-img'> <img src="<?php echo
$category_sub->getImageUrl()?>" alt="<?php echo
$category_sub->getName()?>"></img>
</div>
<?php //echo $category_sub->getName()?></a>
</div>
<?php endforeach; ?>
</div>
<?php } ?>
add a comment |
You need to customized the category in the theme folder use the
following file structure and update the following code
/app/design/frontend/<vendor>/theme/Magento_Catalog/templates/category
products.phtml
<?php
// call current category and sub category
$categoryHelper_sub = $this->helper('MagentoCatalogHelperCategory');
$_category = $block->getCurrentCategory();
$objectManager_sub = $objectManager =
MagentoFrameworkAppObjectManager::getInstance();
$imagehelper = $objectManager->create('MagentoCatalogHelperImage');
$category = $objectManager_sub->get('MagentoCatalogModelCategory');
$categories_sub =
$category->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('is_active',
1)->addIdFilter($_category->getChildren())->setOrder('position', 'ASC');?>
<?php if(!empty($categories_sub->getData())){ ?>
<div class="page-products">
<div class="products wrapper grid products-grid">
<div class="col-xs-12 abt_head caps">
<h2><?php echo $_category->getName(); ?></h2>
<p><?php echo $_category->getDescription(); ?></p>
<div class="current-image">
<img src="<?php echo $_category->getImageUrl()?>" >
</div>
</div>
<?php foreach($categories_sub as $category_sub): ?>
<?php $category_sub->getParentId();
$categoryobj =
$objectManager->create('MagentoCatalogModelCategoryFactory');
$category =
$objectManager->get('MagentoFrameworkRegistry')->registry('current_category');//get
current category
$category_sub->getChildren();?>
<div class='submenu'>
<a href="<?php echo
$categoryHelper_sub->getCategoryUrl($category_sub);?>">
<div class='submenu-img'> <img src="<?php echo
$category_sub->getImageUrl()?>" alt="<?php echo
$category_sub->getName()?>"></img>
</div>
<?php //echo $category_sub->getName()?></a>
</div>
<?php endforeach; ?>
</div>
<?php } ?>
You need to customized the category in the theme folder use the
following file structure and update the following code
/app/design/frontend/<vendor>/theme/Magento_Catalog/templates/category
products.phtml
<?php
// call current category and sub category
$categoryHelper_sub = $this->helper('MagentoCatalogHelperCategory');
$_category = $block->getCurrentCategory();
$objectManager_sub = $objectManager =
MagentoFrameworkAppObjectManager::getInstance();
$imagehelper = $objectManager->create('MagentoCatalogHelperImage');
$category = $objectManager_sub->get('MagentoCatalogModelCategory');
$categories_sub =
$category->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('is_active',
1)->addIdFilter($_category->getChildren())->setOrder('position', 'ASC');?>
<?php if(!empty($categories_sub->getData())){ ?>
<div class="page-products">
<div class="products wrapper grid products-grid">
<div class="col-xs-12 abt_head caps">
<h2><?php echo $_category->getName(); ?></h2>
<p><?php echo $_category->getDescription(); ?></p>
<div class="current-image">
<img src="<?php echo $_category->getImageUrl()?>" >
</div>
</div>
<?php foreach($categories_sub as $category_sub): ?>
<?php $category_sub->getParentId();
$categoryobj =
$objectManager->create('MagentoCatalogModelCategoryFactory');
$category =
$objectManager->get('MagentoFrameworkRegistry')->registry('current_category');//get
current category
$category_sub->getChildren();?>
<div class='submenu'>
<a href="<?php echo
$categoryHelper_sub->getCategoryUrl($category_sub);?>">
<div class='submenu-img'> <img src="<?php echo
$category_sub->getImageUrl()?>" alt="<?php echo
$category_sub->getName()?>"></img>
</div>
<?php //echo $category_sub->getName()?></a>
</div>
<?php endforeach; ?>
</div>
<?php } ?>
answered Oct 19 '16 at 6:03
Abhinav SinghAbhinav Singh
2,115612
2,115612
add a comment |
add a comment |
I have create small module for display sub category please check this link.
https://github.com/pratikmage/magento2-subcategory
add a comment |
I have create small module for display sub category please check this link.
https://github.com/pratikmage/magento2-subcategory
add a comment |
I have create small module for display sub category please check this link.
https://github.com/pratikmage/magento2-subcategory
I have create small module for display sub category please check this link.
https://github.com/pratikmage/magento2-subcategory
answered Jan 11 '17 at 11:26
PratikPratik
2,23351342
2,23351342
add a comment |
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 12 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%2f141236%2fdisplaying-subcategories-instead-of-products-2-1%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