Hot answers tagged

24

Solution 1 : You need to have all your categories UNDER the "Default Category". Then they should show. Solution 2 : Verify that Default Category Is Active (Enable category = "yes") and "Include in Navigation Menu" to Yes. Clear your cache by running the php bin/magento cache:clean command and check it will works. Update : Just go to the Stores -> All ...


13

I had the same issue, I found a solution for this. I just removed the ttl attribute from /vendor/magento/module-theme/view/frontend/layout/default.xml and the menu bar appeared again.


12

Look at vendor/magento/module-catalog/etc/di.xml <type name="Magento\Theme\Block\Html\Topmenu"> <plugin name="catalogTopmenu" type="Magento\Catalog\Plugin\Block\Topmenu" /> </type> As we can see, Magento uses Plugin - Magento\Catalog\Plugin\Block\Topmenu to override some methods of Magento\Theme\Block\Html\Topmenu class. We ...


12

copy file from vendor/magento/module-theme/view/frontend/templates/html/topmenu.phtml and put this file in your theme location app/design/frontend/Vendor/YourTheme/Magento_Theme/templates/html/topmenu.phtml Add below <li> structure just after <?php /* @escapeNotVerified */ echo $block->getChildHtml(); ?> line in topmenu.phtml <li ...


10

Late to the party here, and I think you've probably already figured it out by now, but you need to have categories UNDER the "Default Category". Then they should show.


10

You can do it with a Plugin. In a custom module: add magento\app\code\Custom\Module\etc\frontend\di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Theme\Block\Html\Topmenu"> <plugin ...


9

You need to add below css in your custom CSS / LESS file . I think I have already stated you before how to add custom CSS / LESS. .navigation .level0 .submenu{ top:30px !important; <!-- adjust this value as you required, this is just for sample--> }


9

Another alternative is to use a new template file via layout xml. ./app/design/frontend/Company/Yourtheme/Magento_Theme/layout/default.xml <?xml version="1.0"?> <!-- /** * Copyright info. */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/...


6

1) To remove sign up and sign in links edit your default.xml code at below location. /app/design/frontend/Infortis/base/Magento_Theme/layout/default.xml Add these lines of code <referenceBlock name="top.links"> <referenceBlock name="register-link" remove="true" /> <!--for sign up Link--> <referenceBlock name="...


6

Login to Admin: Step 1) Click on Catalog >> Categories. Step 2) Select Category you want to add in main menu. And select "Include in Menu" => Yes Step 3) Run command php bin/magento cache:flush Now check in frontend category show in main menu. Done.


5

I know this is an old question but I just worked on a solution for this. So if anyone else is having this issue... Have a look at the Magento\Catalog\Plugin\Block\Topmenu This is where Magento fills category tree for the menu. Since this one is a plugin I decided to disable it and add a new plugin with same content (+my modifications) in my module. ...


5

If you have tried all the other solutions and checked all the other basic things (enabled, correct root category...) then I might have the solution for you! If the category was every removed from the menu ("Include in Menu" = "Off" in admin), and then turned back on; it seems there is a bug in Magento 2 here. Magento 2 will only set the "include_in_menu" ...


5

A little bit code modification is need in your code. Open your di.xml then put sortOrder="-1" Using this sortOrder="[NumericValue]" tag you can arrange sequesce of execution of plugin for the same method. plugin sortOrder: The order in which plugins that call the same method are run. see http://devdocs.magento.com/guides/v2.0/extension-dev-...


5

You can add elements to the top menu using the event page_block_html_topmenu_gethtml_before. Step 1 - So you need to create a module with these files (all the files should be in app/code/[Namespace]/[Module]): Step 2 - app/code/[Namespace]/[Module]/etc/module.xml - the module declaration file <?xml version="1.0"?> <config xmlns:xsi="...


4

Okay, I came up with a solution. It may not be ideal, but it works for me. Hopefully somebody will find it useful. It will depend on the base theme you're using, but first of all I had to comment out this line in styles-m.css: .navigation .submenu:not(:first-child).expanded { // display: block !important; ... } In my own mobile stylesheet, that's set ...


4

In your theme, make this file: Your/theme/Magento_Theme/templates/html/topmenu.phtml <?php /** * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ // @codingStandardsIgnoreFile ?> <?php /** * Top menu for store * * @var $block \Magento\Theme\Block\Html\Topmenu */ ?> <?php $columnsLimit = $block-...


4

I have found the solution so I am answering it. Menu content in M2 is generated from Block - vendor/magento/module-theme/Block/Html/Topmenu.php To make changes in HTML structure, we need to override the Block in our custom Package Module say app/code/Mypackage/Mymodule/Block/Html/Topmenu.php Sample code to override <?php namespace Mypackage\Mymodule\...


4

Try following code: app/code/[VendorName]/[ModuleName]/registration.php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, '[VendorName]_[ModuleName]', __DIR__ ); app/code/[VendorName]/[ModuleName]/etc/module.xml <config xmlns:xsi="http://www.w3.org/2001/...


4

From my understanding, there is no perfect solution to this issue. Whatever fix you decide to implement will have its drawbacks. I think there may also be 2 other techniques that you can use which are ESI (Edge Side Includes) or hole punching. Although I don't have any experience or knowledge about these, so if these are valid techniques for this purpose. I'...


3

Copy this code on your magento root dir and run it from url. <html> <body> <?php error_reporting(E_ALL | E_STRICT); $mageFilename = 'app/Mage.php'; require_once $mageFilename; Mage::setIsDeveloperMode(true); ini_set('display_errors', 1); ini_set('memory_limit', '600M'); ini_set('max_execution_time', ...


3

The menu is a jQuery UI element. You can edit its settings by extending the following file in your theme: Magento_Theme/view/frontend/templates/html/topmenu.phtml it says: <nav class="navigation" data-action="navigation"> <ul data-mage-init='{"menu":{"responsive":true, "expanded":true, "position":{"my":"left top","at":"left bottom"}}}'> ...


3

When you create a website, you also create store group(s) and store view(s). Each store group have its own catalog root, so your top menu can be different if you have set different root categories. Furthermore, you can configure different design for your store views. So you can change the layouts and templates per views (or per website if you only have one ...


3

I followed some suggestions from this Magento Forum post, but none of them did the trick for me, but the last one was close. Here's what I did: Copy /app/code/core/Mage/Wishlist/Block/Links.php to /app/code/local/Mage/Wishlist/Block/Links.php Inside the _toHtml() method, add $this->a_params = 'class="your-class"'; just before the return parent::_toHtml();...


3

Add Some CSS tweaks to open menu smoothly with some delay rather than instantly To add custom CSS/LESS always better to use _extend.less See detailed answer for using _extend.less https://magento.stackexchange.com/a/195712/54588 Now in your _extend.less paste below css code .page-header.header-newskin .navigation li.level0.fullwidth .submenu { ...


3

There is a issue with plugin order In default Magento already plugin define in vendor/magento/module-catalog/etc/di.xml <type name="Magento\Theme\Block\Html\Topmenu"> <plugin name="catalogTopmenu" type="Magento\Catalog\Plugin\Block\Topmenu" /> </type> And we created custom plugin in app\code{VendorName}{ModuleName}\etc\di.xml <...


3

Open vendor/magento/module-catalog/Plugin/Block/Topmenu.php The constructor of this class looks like public function __construct( \Magento\Catalog\Helper\Category $catalogCategory, \Magento\Catalog\Model\ResourceModel\Category\StateDependentCollectionFactory $categoryCollectionFactory, \Magento\Store\Model\StoreManagerInterface $...


3

as per screenshot https://prnt.sc/laljiy please put "Outfits", "shops" and "sale" category as child of "default category". Let me know if it works.


3

Go to Admin > Port > Porto - Settings Panel > Header Type you find your selected header type. In that selected type Header 3 for exemple you'll find : <?php echo $this->getChildHtml('topLinks'); ?>, this topLinks refers to customer.xml and that links are added via xml something like this: <default> <reference name="top.links"&...


3

The categories are added to the menu using a plugin Magento\Catalog\Plugin\Block\Topmenu::beforeGetHtml. Since you replaced the core block with yours, this plugin does not get executed. Make your class extend Magento\Theme\Block\Html\Topmenu. Plugins will be called for child classes also, hence it will be called for yours.


3

1.Please add below method on your block class public function getSubcategories($categories) { $array =''; if($categories->getChildrenCount()>0){ $array= '<ul class="child">'; foreach($categories->getChildrenCategories() as $category) { $array .= '<li>'. '<a href="' .$category-&...


Only top voted, non community-wiki answers of a minimum length are eligible