質問

How can I add a Menu item in Magento 2 default Luma Theme ?

enter image description here

役に立ちましたか?

解決

Static menu is not good practise. You should create sub menu in default category.

But, For static menu you need to overrride topmenu.phtml at app/design/frontend/<vendor_name>/<theme_name>/Magento_Theme/templates/html/

You can copy from your vendor/magento/module-theme/view/frontend/templates/html/topmenu.phtml and paste in your theme phtml like below way :

<?php
/**
 * Copyright © Magento, Inc. 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->getColumnsLimit() ?: 0; ?>
<?php $_menu = $block->getHtml('level-top', 'submenu', $columnsLimit) ?>

<nav class="navigation" data-action="navigation">
    <ul data-mage-init='{"menu":{"responsive":true, "expanded":true, "position":{"my":"left top","at":"left bottom"}}}'>
        <?= /* @escapeNotVerified */ $_menu ?>
        <?= /* @escapeNotVerified */ $block->getChildHtml() ?>
        <li class="level0 nav-7 category-item last level-top ui-menu-item" role="presentation">
            <a href="#" class="level-top ui-corner-all" id="ui-id-8" tabindex="-1" role="menuitem">
                <span>New Menu</span>
            </a>
        </li>
    </ul>
</nav>
ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top