Display categories and sub-categories The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)How do display category icons/images when top-level category is selected?how to display sub-sub categories on left sideFatal error when I go 'Manage categories' on adminExclude a specific categoryScript to hide empty categories works but not with products without stockfunction to display menu from a set levelFilter category collection with nested OR/AND statementsDisplay categories and sub-categories : where to paste the code?Correcting Parent Categories of Categories that failed to create correctlySub Category - Load By Attribute (name) URL issue, how to resolve?

Is every episode of "Where are my Pants?" identical?

60's-70's movie: home appliances revolting against the owners

Using dividends to reduce short term capital gains?

Can the DM override racial traits?

What force causes entropy to increase?

Store Dynamic-accessible hidden metadata in a cell

Are spiders unable to hurt humans, especially very small spiders?

Do ℕ, mathbbN, BbbN, symbbN effectively differ, and is there a "canonical" specification of the naturals?

Do working physicists consider Newtonian mechanics to be "falsified"?

Student Loan from years ago pops up and is taking my salary

Does Parliament hold absolute power in the UK?

How did passengers keep warm on sail ships?

Why can't devices on different VLANs, but on the same subnet, communicate?

Can each chord in a progression create its own key?

Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?

"... to apply for a visa" or "... and applied for a visa"?

how can a perfect fourth interval be considered either consonant or dissonant?

Do I have Disadvantage attacking with an off-hand weapon?

Is this wall load bearing? Blueprints and photos attached

Is there a way to generate uniformly distributed points on a sphere from a fixed amount of random real numbers per point?

Variable with quotation marks "$()"

Why doesn't a hydraulic lever violate conservation of energy?

How do I design a circuit to convert a 100 mV and 50 Hz sine wave to a square wave?

For what reasons would an animal species NOT cross a *horizontal* land bridge?



Display categories and sub-categories



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)How do display category icons/images when top-level category is selected?how to display sub-sub categories on left sideFatal error when I go 'Manage categories' on adminExclude a specific categoryScript to hide empty categories works but not with products without stockfunction to display menu from a set levelFilter category collection with nested OR/AND statementsDisplay categories and sub-categories : where to paste the code?Correcting Parent Categories of Categories that failed to create correctlySub Category - Load By Attribute (name) URL issue, how to resolve?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I'm tryng to display categories and subcategories on a cms page



<?php 
$categories = Mage::getModel('catalog/category')
->getCollection()
->addAttributeToSelect('*')
->addIsActiveFilter();
foreach ($_categories->getStoreCategories() as $_category)
$category = Mage::getModel('catalog/category');
$category->load($_category->getId());
$subcategories = explode(',', $category->getChildren());
?>
<dl>
<dt><?php echo $this->htmlEscape($_category->getName()); ?>
</dt>
<dd>
<ol>
<?php
foreach ($subcategories as $subcategoryId)
$category->load($subcategoryId);
echo '<li><a href="' . $category->getURL() . '">' . $category->getName() . '</a></li>';

?>
</ol>
</dd>
</dl>
<?php

?>


But this is returning me a fatal error Fatal error: Call to a member function getStoreCategories() on null on line 5










share|improve this question
















bumped to the homepage by Community 6 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • change $_categories->getStoreCategories() to $categories->getStoreCategories() i thing $_categories variabale is not define there

    – Vaibhav Ahalpara
    Oct 26 '16 at 11:52

















2















I'm tryng to display categories and subcategories on a cms page



<?php 
$categories = Mage::getModel('catalog/category')
->getCollection()
->addAttributeToSelect('*')
->addIsActiveFilter();
foreach ($_categories->getStoreCategories() as $_category)
$category = Mage::getModel('catalog/category');
$category->load($_category->getId());
$subcategories = explode(',', $category->getChildren());
?>
<dl>
<dt><?php echo $this->htmlEscape($_category->getName()); ?>
</dt>
<dd>
<ol>
<?php
foreach ($subcategories as $subcategoryId)
$category->load($subcategoryId);
echo '<li><a href="' . $category->getURL() . '">' . $category->getName() . '</a></li>';

?>
</ol>
</dd>
</dl>
<?php

?>


But this is returning me a fatal error Fatal error: Call to a member function getStoreCategories() on null on line 5










share|improve this question
















bumped to the homepage by Community 6 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • change $_categories->getStoreCategories() to $categories->getStoreCategories() i thing $_categories variabale is not define there

    – Vaibhav Ahalpara
    Oct 26 '16 at 11:52













2












2








2


1






I'm tryng to display categories and subcategories on a cms page



<?php 
$categories = Mage::getModel('catalog/category')
->getCollection()
->addAttributeToSelect('*')
->addIsActiveFilter();
foreach ($_categories->getStoreCategories() as $_category)
$category = Mage::getModel('catalog/category');
$category->load($_category->getId());
$subcategories = explode(',', $category->getChildren());
?>
<dl>
<dt><?php echo $this->htmlEscape($_category->getName()); ?>
</dt>
<dd>
<ol>
<?php
foreach ($subcategories as $subcategoryId)
$category->load($subcategoryId);
echo '<li><a href="' . $category->getURL() . '">' . $category->getName() . '</a></li>';

?>
</ol>
</dd>
</dl>
<?php

?>


But this is returning me a fatal error Fatal error: Call to a member function getStoreCategories() on null on line 5










share|improve this question
















I'm tryng to display categories and subcategories on a cms page



<?php 
$categories = Mage::getModel('catalog/category')
->getCollection()
->addAttributeToSelect('*')
->addIsActiveFilter();
foreach ($_categories->getStoreCategories() as $_category)
$category = Mage::getModel('catalog/category');
$category->load($_category->getId());
$subcategories = explode(',', $category->getChildren());
?>
<dl>
<dt><?php echo $this->htmlEscape($_category->getName()); ?>
</dt>
<dd>
<ol>
<?php
foreach ($subcategories as $subcategoryId)
$category->load($subcategoryId);
echo '<li><a href="' . $category->getURL() . '">' . $category->getName() . '</a></li>';

?>
</ol>
</dd>
</dl>
<?php

?>


But this is returning me a fatal error Fatal error: Call to a member function getStoreCategories() on null on line 5







category category-products category-tree






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 25 '17 at 19:42









Ankur140290

1033




1033










asked Oct 24 '16 at 20:43









yavonz15yavonz15

161216




161216





bumped to the homepage by Community 6 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 6 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • change $_categories->getStoreCategories() to $categories->getStoreCategories() i thing $_categories variabale is not define there

    – Vaibhav Ahalpara
    Oct 26 '16 at 11:52

















  • change $_categories->getStoreCategories() to $categories->getStoreCategories() i thing $_categories variabale is not define there

    – Vaibhav Ahalpara
    Oct 26 '16 at 11:52
















change $_categories->getStoreCategories() to $categories->getStoreCategories() i thing $_categories variabale is not define there

– Vaibhav Ahalpara
Oct 26 '16 at 11:52





change $_categories->getStoreCategories() to $categories->getStoreCategories() i thing $_categories variabale is not define there

– Vaibhav Ahalpara
Oct 26 '16 at 11:52










2 Answers
2






active

oldest

votes


















0














You can try below code for display all store category and subcategories.



<?php
$_helper = Mage::helper('catalog/category');
$categories = $_helper->getStoreCategories();

foreach ($categories as $_category)
$category = Mage::getModel('catalog/category')->load($_category->getId());
$subcategories = $category->getChildrenCategories();
?>
<dl>
<dt><?php echo $this->htmlEscape($_category->getName()); ?></dt>
<dd>
<ol>
<?php
foreach ($subcategories as $_subcategory)
echo '<li><a href="' . $_subcategory->getURL() . '">' . $_subcategory->getName() . '</a></li>';

?>
</ol>
</dd>
</dl>
<?php


?>


Let me know if you have any query from above.






share|improve this answer























  • This will only work in one level, if subcategories have their own subcategories then?

    – Haris
    Nov 27 '17 at 19:15


















0














Please follow the below steps:



Step 1: Create new_list.phtml in frontend/your_theme/default/template/catalog/category and paste the below code :



 ================code starts here================

<div class="block block-list block-categories">
<div id="block-categories" class="block-title active">
<strong><span>Categories </span></strong>
</div>
<div id="leftnav" class="block-content" style="display:block">
<?php $helper = $this->helper('catalog/category') ?>
<?php $categories = $this->getStoreCategories() ?>
<?php if (count($categories) > 0): ?>
<ul id="leftnav-tree" class="level0">
<?php foreach($categories as $category): ?>
<li class="level0<?php if ($this->isCategoryActive($category)): ?> active<?php endif; ?>">
<a href="<?php echo $helper->getCategoryUrl($category) ?>"><span><?php echo $this->escapeHtml($category->getName()) ?></span></a>
<?php //if ($this->isCategoryActive($category)): ?>
<?php $subcategories = $category->getChildren() ?>
<?php if (count($subcategories) > 0): ?>
<ul id="leftnav-tree-<?php echo $category->getId() ?>" class="level1">
<?php foreach($subcategories as $subcategory): ?>
<li class="level1<?php if ($this->isCategoryActive($subcategory)): ?> active<?php endif; ?>">
<a href="<?php echo $helper->getCategoryUrl($subcategory) ?>"><?php echo $this->escapeHtml(trim($subcategory->getName(), '- ')) ?></a>
<?php $secondLevelSubcategories = $subcategory->getChildren() ?>
<?php if (count($secondLevelSubcategories ) > 0): ?>
<ul id="leftnav-tree-<?php echo $subcategory->getId() ?>" class="level2">
<?php foreach($secondLevelSubcategories as $secondLevelSubcategory ): ?>
<li class="level2<?php if ($this->isCategoryActive($secondLevelSubcategory )): ?> active<?php endif; ?>">
<a href="<?php echo $helper->getCategoryUrl($secondLevelSubcategory ) ?>"><?php echo $this->escapeHtml(trim($secondLevelSubcategory ->getName(), '- ')) ?></a>
</li>
<?php endforeach; ?>
</ul>
<script type="text/javascript">decorateList('leftnav-tree-<?php echo $category->getId() ?>', 'recursive')</script>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<script type="text/javascript">decorateList('leftnav-tree-<?php echo $category->getId() ?>', 'recursive')</script>
<?php endif; ?>
<?php //endif; ?>
</li>
<?php endforeach; ?>
</ul>
<script type="text/javascript">decorateList('leftnav-tree', 'recursive')</script>
<?php endif; ?>
</div>
</div>

===============code ends here===============


Step 2 : Call new_list.phtml in your CMS page or static block:



block type="catalog/navigation" name="catalog.category" template="catalog/category/new_list.phtml"


Hope, it will help.






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%2f142430%2fdisplay-categories-and-sub-categories%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









    0














    You can try below code for display all store category and subcategories.



    <?php
    $_helper = Mage::helper('catalog/category');
    $categories = $_helper->getStoreCategories();

    foreach ($categories as $_category)
    $category = Mage::getModel('catalog/category')->load($_category->getId());
    $subcategories = $category->getChildrenCategories();
    ?>
    <dl>
    <dt><?php echo $this->htmlEscape($_category->getName()); ?></dt>
    <dd>
    <ol>
    <?php
    foreach ($subcategories as $_subcategory)
    echo '<li><a href="' . $_subcategory->getURL() . '">' . $_subcategory->getName() . '</a></li>';

    ?>
    </ol>
    </dd>
    </dl>
    <?php


    ?>


    Let me know if you have any query from above.






    share|improve this answer























    • This will only work in one level, if subcategories have their own subcategories then?

      – Haris
      Nov 27 '17 at 19:15















    0














    You can try below code for display all store category and subcategories.



    <?php
    $_helper = Mage::helper('catalog/category');
    $categories = $_helper->getStoreCategories();

    foreach ($categories as $_category)
    $category = Mage::getModel('catalog/category')->load($_category->getId());
    $subcategories = $category->getChildrenCategories();
    ?>
    <dl>
    <dt><?php echo $this->htmlEscape($_category->getName()); ?></dt>
    <dd>
    <ol>
    <?php
    foreach ($subcategories as $_subcategory)
    echo '<li><a href="' . $_subcategory->getURL() . '">' . $_subcategory->getName() . '</a></li>';

    ?>
    </ol>
    </dd>
    </dl>
    <?php


    ?>


    Let me know if you have any query from above.






    share|improve this answer























    • This will only work in one level, if subcategories have their own subcategories then?

      – Haris
      Nov 27 '17 at 19:15













    0












    0








    0







    You can try below code for display all store category and subcategories.



    <?php
    $_helper = Mage::helper('catalog/category');
    $categories = $_helper->getStoreCategories();

    foreach ($categories as $_category)
    $category = Mage::getModel('catalog/category')->load($_category->getId());
    $subcategories = $category->getChildrenCategories();
    ?>
    <dl>
    <dt><?php echo $this->htmlEscape($_category->getName()); ?></dt>
    <dd>
    <ol>
    <?php
    foreach ($subcategories as $_subcategory)
    echo '<li><a href="' . $_subcategory->getURL() . '">' . $_subcategory->getName() . '</a></li>';

    ?>
    </ol>
    </dd>
    </dl>
    <?php


    ?>


    Let me know if you have any query from above.






    share|improve this answer













    You can try below code for display all store category and subcategories.



    <?php
    $_helper = Mage::helper('catalog/category');
    $categories = $_helper->getStoreCategories();

    foreach ($categories as $_category)
    $category = Mage::getModel('catalog/category')->load($_category->getId());
    $subcategories = $category->getChildrenCategories();
    ?>
    <dl>
    <dt><?php echo $this->htmlEscape($_category->getName()); ?></dt>
    <dd>
    <ol>
    <?php
    foreach ($subcategories as $_subcategory)
    echo '<li><a href="' . $_subcategory->getURL() . '">' . $_subcategory->getName() . '</a></li>';

    ?>
    </ol>
    </dd>
    </dl>
    <?php


    ?>


    Let me know if you have any query from above.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Oct 25 '16 at 6:50









    Suresh ChikaniSuresh Chikani

    10.5k53471




    10.5k53471












    • This will only work in one level, if subcategories have their own subcategories then?

      – Haris
      Nov 27 '17 at 19:15

















    • This will only work in one level, if subcategories have their own subcategories then?

      – Haris
      Nov 27 '17 at 19:15
















    This will only work in one level, if subcategories have their own subcategories then?

    – Haris
    Nov 27 '17 at 19:15





    This will only work in one level, if subcategories have their own subcategories then?

    – Haris
    Nov 27 '17 at 19:15













    0














    Please follow the below steps:



    Step 1: Create new_list.phtml in frontend/your_theme/default/template/catalog/category and paste the below code :



     ================code starts here================

    <div class="block block-list block-categories">
    <div id="block-categories" class="block-title active">
    <strong><span>Categories </span></strong>
    </div>
    <div id="leftnav" class="block-content" style="display:block">
    <?php $helper = $this->helper('catalog/category') ?>
    <?php $categories = $this->getStoreCategories() ?>
    <?php if (count($categories) > 0): ?>
    <ul id="leftnav-tree" class="level0">
    <?php foreach($categories as $category): ?>
    <li class="level0<?php if ($this->isCategoryActive($category)): ?> active<?php endif; ?>">
    <a href="<?php echo $helper->getCategoryUrl($category) ?>"><span><?php echo $this->escapeHtml($category->getName()) ?></span></a>
    <?php //if ($this->isCategoryActive($category)): ?>
    <?php $subcategories = $category->getChildren() ?>
    <?php if (count($subcategories) > 0): ?>
    <ul id="leftnav-tree-<?php echo $category->getId() ?>" class="level1">
    <?php foreach($subcategories as $subcategory): ?>
    <li class="level1<?php if ($this->isCategoryActive($subcategory)): ?> active<?php endif; ?>">
    <a href="<?php echo $helper->getCategoryUrl($subcategory) ?>"><?php echo $this->escapeHtml(trim($subcategory->getName(), '- ')) ?></a>
    <?php $secondLevelSubcategories = $subcategory->getChildren() ?>
    <?php if (count($secondLevelSubcategories ) > 0): ?>
    <ul id="leftnav-tree-<?php echo $subcategory->getId() ?>" class="level2">
    <?php foreach($secondLevelSubcategories as $secondLevelSubcategory ): ?>
    <li class="level2<?php if ($this->isCategoryActive($secondLevelSubcategory )): ?> active<?php endif; ?>">
    <a href="<?php echo $helper->getCategoryUrl($secondLevelSubcategory ) ?>"><?php echo $this->escapeHtml(trim($secondLevelSubcategory ->getName(), '- ')) ?></a>
    </li>
    <?php endforeach; ?>
    </ul>
    <script type="text/javascript">decorateList('leftnav-tree-<?php echo $category->getId() ?>', 'recursive')</script>
    <?php endif; ?>
    <?php endforeach; ?>
    </ul>
    <script type="text/javascript">decorateList('leftnav-tree-<?php echo $category->getId() ?>', 'recursive')</script>
    <?php endif; ?>
    <?php //endif; ?>
    </li>
    <?php endforeach; ?>
    </ul>
    <script type="text/javascript">decorateList('leftnav-tree', 'recursive')</script>
    <?php endif; ?>
    </div>
    </div>

    ===============code ends here===============


    Step 2 : Call new_list.phtml in your CMS page or static block:



    block type="catalog/navigation" name="catalog.category" template="catalog/category/new_list.phtml"


    Hope, it will help.






    share|improve this answer





























      0














      Please follow the below steps:



      Step 1: Create new_list.phtml in frontend/your_theme/default/template/catalog/category and paste the below code :



       ================code starts here================

      <div class="block block-list block-categories">
      <div id="block-categories" class="block-title active">
      <strong><span>Categories </span></strong>
      </div>
      <div id="leftnav" class="block-content" style="display:block">
      <?php $helper = $this->helper('catalog/category') ?>
      <?php $categories = $this->getStoreCategories() ?>
      <?php if (count($categories) > 0): ?>
      <ul id="leftnav-tree" class="level0">
      <?php foreach($categories as $category): ?>
      <li class="level0<?php if ($this->isCategoryActive($category)): ?> active<?php endif; ?>">
      <a href="<?php echo $helper->getCategoryUrl($category) ?>"><span><?php echo $this->escapeHtml($category->getName()) ?></span></a>
      <?php //if ($this->isCategoryActive($category)): ?>
      <?php $subcategories = $category->getChildren() ?>
      <?php if (count($subcategories) > 0): ?>
      <ul id="leftnav-tree-<?php echo $category->getId() ?>" class="level1">
      <?php foreach($subcategories as $subcategory): ?>
      <li class="level1<?php if ($this->isCategoryActive($subcategory)): ?> active<?php endif; ?>">
      <a href="<?php echo $helper->getCategoryUrl($subcategory) ?>"><?php echo $this->escapeHtml(trim($subcategory->getName(), '- ')) ?></a>
      <?php $secondLevelSubcategories = $subcategory->getChildren() ?>
      <?php if (count($secondLevelSubcategories ) > 0): ?>
      <ul id="leftnav-tree-<?php echo $subcategory->getId() ?>" class="level2">
      <?php foreach($secondLevelSubcategories as $secondLevelSubcategory ): ?>
      <li class="level2<?php if ($this->isCategoryActive($secondLevelSubcategory )): ?> active<?php endif; ?>">
      <a href="<?php echo $helper->getCategoryUrl($secondLevelSubcategory ) ?>"><?php echo $this->escapeHtml(trim($secondLevelSubcategory ->getName(), '- ')) ?></a>
      </li>
      <?php endforeach; ?>
      </ul>
      <script type="text/javascript">decorateList('leftnav-tree-<?php echo $category->getId() ?>', 'recursive')</script>
      <?php endif; ?>
      <?php endforeach; ?>
      </ul>
      <script type="text/javascript">decorateList('leftnav-tree-<?php echo $category->getId() ?>', 'recursive')</script>
      <?php endif; ?>
      <?php //endif; ?>
      </li>
      <?php endforeach; ?>
      </ul>
      <script type="text/javascript">decorateList('leftnav-tree', 'recursive')</script>
      <?php endif; ?>
      </div>
      </div>

      ===============code ends here===============


      Step 2 : Call new_list.phtml in your CMS page or static block:



      block type="catalog/navigation" name="catalog.category" template="catalog/category/new_list.phtml"


      Hope, it will help.






      share|improve this answer



























        0












        0








        0







        Please follow the below steps:



        Step 1: Create new_list.phtml in frontend/your_theme/default/template/catalog/category and paste the below code :



         ================code starts here================

        <div class="block block-list block-categories">
        <div id="block-categories" class="block-title active">
        <strong><span>Categories </span></strong>
        </div>
        <div id="leftnav" class="block-content" style="display:block">
        <?php $helper = $this->helper('catalog/category') ?>
        <?php $categories = $this->getStoreCategories() ?>
        <?php if (count($categories) > 0): ?>
        <ul id="leftnav-tree" class="level0">
        <?php foreach($categories as $category): ?>
        <li class="level0<?php if ($this->isCategoryActive($category)): ?> active<?php endif; ?>">
        <a href="<?php echo $helper->getCategoryUrl($category) ?>"><span><?php echo $this->escapeHtml($category->getName()) ?></span></a>
        <?php //if ($this->isCategoryActive($category)): ?>
        <?php $subcategories = $category->getChildren() ?>
        <?php if (count($subcategories) > 0): ?>
        <ul id="leftnav-tree-<?php echo $category->getId() ?>" class="level1">
        <?php foreach($subcategories as $subcategory): ?>
        <li class="level1<?php if ($this->isCategoryActive($subcategory)): ?> active<?php endif; ?>">
        <a href="<?php echo $helper->getCategoryUrl($subcategory) ?>"><?php echo $this->escapeHtml(trim($subcategory->getName(), '- ')) ?></a>
        <?php $secondLevelSubcategories = $subcategory->getChildren() ?>
        <?php if (count($secondLevelSubcategories ) > 0): ?>
        <ul id="leftnav-tree-<?php echo $subcategory->getId() ?>" class="level2">
        <?php foreach($secondLevelSubcategories as $secondLevelSubcategory ): ?>
        <li class="level2<?php if ($this->isCategoryActive($secondLevelSubcategory )): ?> active<?php endif; ?>">
        <a href="<?php echo $helper->getCategoryUrl($secondLevelSubcategory ) ?>"><?php echo $this->escapeHtml(trim($secondLevelSubcategory ->getName(), '- ')) ?></a>
        </li>
        <?php endforeach; ?>
        </ul>
        <script type="text/javascript">decorateList('leftnav-tree-<?php echo $category->getId() ?>', 'recursive')</script>
        <?php endif; ?>
        <?php endforeach; ?>
        </ul>
        <script type="text/javascript">decorateList('leftnav-tree-<?php echo $category->getId() ?>', 'recursive')</script>
        <?php endif; ?>
        <?php //endif; ?>
        </li>
        <?php endforeach; ?>
        </ul>
        <script type="text/javascript">decorateList('leftnav-tree', 'recursive')</script>
        <?php endif; ?>
        </div>
        </div>

        ===============code ends here===============


        Step 2 : Call new_list.phtml in your CMS page or static block:



        block type="catalog/navigation" name="catalog.category" template="catalog/category/new_list.phtml"


        Hope, it will help.






        share|improve this answer















        Please follow the below steps:



        Step 1: Create new_list.phtml in frontend/your_theme/default/template/catalog/category and paste the below code :



         ================code starts here================

        <div class="block block-list block-categories">
        <div id="block-categories" class="block-title active">
        <strong><span>Categories </span></strong>
        </div>
        <div id="leftnav" class="block-content" style="display:block">
        <?php $helper = $this->helper('catalog/category') ?>
        <?php $categories = $this->getStoreCategories() ?>
        <?php if (count($categories) > 0): ?>
        <ul id="leftnav-tree" class="level0">
        <?php foreach($categories as $category): ?>
        <li class="level0<?php if ($this->isCategoryActive($category)): ?> active<?php endif; ?>">
        <a href="<?php echo $helper->getCategoryUrl($category) ?>"><span><?php echo $this->escapeHtml($category->getName()) ?></span></a>
        <?php //if ($this->isCategoryActive($category)): ?>
        <?php $subcategories = $category->getChildren() ?>
        <?php if (count($subcategories) > 0): ?>
        <ul id="leftnav-tree-<?php echo $category->getId() ?>" class="level1">
        <?php foreach($subcategories as $subcategory): ?>
        <li class="level1<?php if ($this->isCategoryActive($subcategory)): ?> active<?php endif; ?>">
        <a href="<?php echo $helper->getCategoryUrl($subcategory) ?>"><?php echo $this->escapeHtml(trim($subcategory->getName(), '- ')) ?></a>
        <?php $secondLevelSubcategories = $subcategory->getChildren() ?>
        <?php if (count($secondLevelSubcategories ) > 0): ?>
        <ul id="leftnav-tree-<?php echo $subcategory->getId() ?>" class="level2">
        <?php foreach($secondLevelSubcategories as $secondLevelSubcategory ): ?>
        <li class="level2<?php if ($this->isCategoryActive($secondLevelSubcategory )): ?> active<?php endif; ?>">
        <a href="<?php echo $helper->getCategoryUrl($secondLevelSubcategory ) ?>"><?php echo $this->escapeHtml(trim($secondLevelSubcategory ->getName(), '- ')) ?></a>
        </li>
        <?php endforeach; ?>
        </ul>
        <script type="text/javascript">decorateList('leftnav-tree-<?php echo $category->getId() ?>', 'recursive')</script>
        <?php endif; ?>
        <?php endforeach; ?>
        </ul>
        <script type="text/javascript">decorateList('leftnav-tree-<?php echo $category->getId() ?>', 'recursive')</script>
        <?php endif; ?>
        <?php //endif; ?>
        </li>
        <?php endforeach; ?>
        </ul>
        <script type="text/javascript">decorateList('leftnav-tree', 'recursive')</script>
        <?php endif; ?>
        </div>
        </div>

        ===============code ends here===============


        Step 2 : Call new_list.phtml in your CMS page or static block:



        block type="catalog/navigation" name="catalog.category" template="catalog/category/new_list.phtml"


        Hope, it will help.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Aug 30 '18 at 15:01









        Abhishek Panchal

        3,6173929




        3,6173929










        answered Oct 26 '16 at 11:48









        Abhinav SinghAbhinav Singh

        2,135612




        2,135612



























            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%2f142430%2fdisplay-categories-and-sub-categories%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рвиправивши або дописавши її