1

how to create a custom mega menu in magento 1.x like below image

enter image description here

5
  • i have created same menu but not view more functionality added Commented Feb 25, 2019 at 8:21
  • can u explain me how to create a mega menu @rakesh Commented Feb 25, 2019 at 8:32
  • check my answer and create custom menu template file and add this code Commented Feb 25, 2019 at 8:42
  • how could i create a custom menu template @rakesh Commented Feb 25, 2019 at 10:38
  • you can default menu commented and custom menu create below way create custom phtml file and call in header file Commented Feb 26, 2019 at 5:46

1 Answer 1

1

This code working and i have tested also you can just "carparts" category hover below ul show and then working code

<ul class="all-category-list" role="menu">
    <?php
        $obj = new Mage_Catalog_Block_Navigation();
        $storeCategories = $obj->getStoreCategories();
        Mage::registry('current_category') ? $currentCategoryId = Mage::registry('current_category')->getId() : $currentCategoryId='';
        foreach ($storeCategories as $_category):
    ?>
            <li>
                <a class="d-block text-black px-3 py-3 position-relative" href="<?php echo $_category->getUrl(); ?>"><?php echo $_category->getName(); ?><i class="fa fa-arrow-right font-size-10 text-pink mr-3 position-absolute rightside-arrow"></i></a>
                <?php $categoryChildren = $_category->getChildren(); ?>
                <?php if($categoryChildren->count()) : ?>
                    <ul class="sub-category position-absolute animated fadeInLeft">

                        <?php foreach($categoryChildren as $_categoryChild) : ?>
                            <?php $_categoryChildModel = Mage::getModel('catalog/category')->load($_categoryChild->getId());?>
                            <?php $categoryGrandchildren=$_categoryChild->getChildren(); ?>
                            <li> <?php
                                    $currentCategoryId===$_categoryChild->getId() ? $bold="style=\"font-weight:bold\"" : $bold='';
                                    echo '<a href="' . $_categoryChildModel->getUrl() . '"' . $bold . ' class="d-block text-black px-2 py-1 font-weight-medium font-size-15 my-3 mx-3">' .  $_categoryChild->getName() . '</a>';
                                ?>

                            <?php if($categoryGrandchildren->count()) : ?>
                              <ul class="child-sub-category my-3 mx-3">
                                <?php foreach($categoryGrandchildren as $_categoryGrandchild) : ?>
                                    <?php $_categoryGrandchildModel = Mage::getModel('catalog/category')->load($_categoryGrandchild->getId());?>
                                    <li>
                                        <?php
                                            $currentCategoryId===$_categoryChild->getId() ? $bold="style=\"font-weight:bold\"" : $bold='';
                                            echo '<a href="' . $_categoryGrandchildModel->getUrl() . '"' . $bold . ' class="d-block text-black px-2 py-1">' .  $_categoryGrandchild->getName() . '</a>';
                                        ?>
                                    </li>
                                <?php endforeach; ?>
                                </ul>
                                <?php if($categoryGrandchildren->count() >4): ?>
                                    <a href=""><?php echo $this->__("..View More")?></a>
                                 <?php ?>
                            <?php endif; ?>
                            </li>
                        <?php endforeach; ?>
                    </ul>
                <?php endif; ?>
            </li>
        <?php endforeach ?>
</ul>
1
  • In my case, I can solve it by jQuery functions i was upvoted your answer it will help me for future reference @rakesh Commented Mar 9, 2019 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.