Magento – How to find the block to override for the navigation menu magento 2

frontendmagento2menumodulenavigation

current setup:

  • Magento 2.2.4 installed with composer.

I want to replace the navigation menu with a different navigation menu (MCP Menu Creator Pro). I think I am supposed to extend the magento/module-theme default.xml layout under the Magento_Theme folder in my Pearl/weltpixel/Magento_Theme/

My questions are:

1) how do I find the block name of the navigation block I want to replace? when viewing the home page even with the hints turned on under Stores->Configuration->Advanced->Developer->Debug I am not able to reliably find the block I want to replace

2) I was given this block to add for Menu Creator Pro:

<block class="Magebay\Menupro\Block\Menu" name="menupro_group_1" ifconfig="menupro/setting/enable" template="Magebay_Menupro::menupro/menupro.phtml">
    <action method="setData"><name>groupmenu_id</name><value>1</value></action>
</block>

Honestly, I am not sure where to put this in the default.xml or what to wrap it with (shouldn't there be some reference that tells magento2 to use this nav menu rather than the default?). When looking through the official magento 2.2 docs, it says that <action> is not the preferred element and one should use an <arguments> element set instead!?

Appreciate the help as I begin to understand the magento 2 structure.

note: the Weltpixel_NavigationLinks module included with the Pearl theme has been disabled by

php bin/magento module:disable WeltPixel_NavigationLinks
php bin/magento setup:upgrade

Best Answer

Two files use for navigation

Magento\Theme\Block\Html\Topmenu.php
Magento\Catalog\Plugin\Block\Topmenu.php