문제

We have created megamenu for our site. But the issue we are facing is that the url is appending if click more than once instead of showing corresponding page.

How to resolve this issue?

Below is the code:

<?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
 */
?>


    <link rel="stylesheet" type="text/css" href="<?php echo $block->getViewFileUrl('css/cart.css')?>">

  <?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
 */
?>



<header class="headers">
  <div class="header-inrs">
    <div class="menu-container">
      <div class="menus contenedor-menu">
        <ul class="clearfix backcolor designmenu">
          <div class="totalmobilelog">
            <div class="lo">
              <a href="http://127.0.0.1/newmagento/customer/account/login/" ><b class="clsml">Login</b></a>
            </div>
            <div class="si">
              <a href="" ><b class="clsml">Sign Up</b></a>
            </div>
          </div>
          <?php
          $categories = $block->getStoreCategories();

          foreach ($categories as $category):

          ?>


          <li><a href="<?php echo $category->getRequestPath();?>"><?php echo $category->getName(); ?>

            <?php
            $subCategories = $block->getCategoryById($category->getId());
            $subCats = $subCategories->getChildrenCategories();
            if(count($subCats) > 0): ?>
              <i class="fa fa-angle-down arrowmm" aria-hidden="true"></i>
            <?php endif; ?>
          </a>
            <ul class="subc">
            <?php
            foreach ($subCats as $subCategory):
            ?>

            <li><a href="<?php echo $subCategory->getRequestPath();?>"><?php echo $subCategory->getName(); ?></a>

          </li>

          <?php endforeach; ?>

        </ul>
        <?php echo $block->getSubcategories($subCategories); ?>
        <?php endforeach; ?>
      </li>
  </ul>
</div>
</div>
</div>
</header>

올바른 솔루션이 없습니다

다른 팁

You can try changing the getRequestPath() with getUrl() to get the category Url Path.

Please use $category->getUrl() and $subCategory->getUrl().

This may be help you to get exact Category URL there.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top