Solution: Magento 2 – Magetique Template – themeforst big menue bug and solution (EN)

Here a problem with Magento 2 Magetique Template and the solution

The Magetique Template has a annoying bug inside the big menue extension. If a category was assigned to big menue but got deleted the complete site crashes and shows this error.

It's about this template https://www.templatemonster.com/de/magento-vorlagen-tipo-62000.html

 

Error is like this

1 exception(s):
Exception #0 (Exception): Notice: Undefined index: category-node-X in /web/app/code/TemplateMonster/Megamenu/Model/Configurator/Row/Column/Category.php on line 21

Instead of "category-node-X" it shows the id of the missing category

 

How to reproduce:

Scenario to generate the bug :
1. add parent ex. main category
2. add child 1
3. add child 1-1
4. add child 2
5. add child 2-1

magetique-template-magento-2-bug-big-menu

6. assign child-1 and child-2 in the mega menu

magetique-template-magento-2-bug-big-menu-02


7. now delete child 1


8. refresh the page

Than whitescreen with this error shows up

Exception #0 (Exception): Notice: Undefined index: category-node-X in /web/app/code/TemplateMonster/Megamenu/Model/Configurator/Row/Column/Category.php on line 21

Solution :
1. disable and then enable respective parent category megamenu whos child categories has been deleted bymistake
2. if it still error displays, disable and then enable option include in menu inside respective parent category

 

Update:

The support ist contacted but did not provide a fix or help. They mentioned only a wrong magento version (we used magento 2.2.7 - latest magento 2.2.X version instead of the suggested 2.2.6 version).

If someone has a bugfix feel free to add in the comments

 

Update 05/2020:

please find here the suggestion from Mark (please find comment below). Our Comment field did a not prober layout of the Code

app/code/TemplateMonster/Megamenu/view/frontend/templates/html/topmenu/block/row/column/category.phtml

“`
getCategory();
if ($category) {
$subCategories = $category->getChildren()->getIterator();
//$showSubcategories = $this->getShowSubcategories($category);
//$numberOfSubcategories = $this->getNumberOfSubcategories($category);
$cssClass = $this->getCssClass($category);
$image = $this->getImage($category);

?>

<li class="item ui-menu-item”>

<img src="” alt=””>

<a href="getUrl(); ?>”>
getMmLabel()): ?>

getName() ?>

getCssClass($subCategory); ?>
getChildren()->getIterator(); ?>
<li class="item ui-menu-item”>
getMmLabel()): ?>

getImage($subCategory)) : ?>
<img src="” alt=””>

<a href="getUrl(); ?>”>getName(); ?>
getShowSubcategories($subCategory); ?>
getNumberOfSubcategories($subCategory); ?>

<ul class="mm-submenu level3 getMmViewMode() ? ‘vm-‘ . $subCategory->getMmViewMode() : ‘vm-static’; ?>”
data-mage-init='{“subMenuViewMode”: {}}’>
<?php for ($i = 0; $i
current(); ?>
getCssClass($curCategory); ?>
<li class="item ui-menu-item”>
getMmLabel()): ?>

getImage($curCategory)) : ?>
<img src="” alt=””>

<a href="getUrl(); ?>”>getName(); ?>

next(); ?>

$numberOfSubcategories): ?>

<a href="getUrl(); ?>”>

“`

5/5 - (1 vote) Hinweis: Keine Sicherstellung der Authentizität dieser Bewertungen

2 Antworten

  1. This solution fixes it forever. Basically, if category doesnt exist, just don't show it. app/code/TemplateMonster/Megamenu/view/frontend/templates/html/topmenu/block/row/column/category.phtml ``` getCategory(); if ($category) { $subCategories = $category->getChildren()->getIterator(); //$showSubcategories = $this->getShowSubcategories($category); //$numberOfSubcategories = $this->getNumberOfSubcategories($category); $cssClass = $this->getCssClass($category); $image = $this->getImage($category); ?> <li class="item ui-menu-item"> <img src="" alt=""> <a href="getUrl(); ?>"> getMmLabel()): ?> getName() ?> </a> getCssClass($subCategory); ?> getChildren()->getIterator(); ?> <li class="item ui-menu-item"> getMmLabel()): ?> getImage($subCategory)) : ?> <img src="" alt=""> <a href="getUrl(); ?>">getName(); ?></a> getShowSubcategories($subCategory); ?> getNumberOfSubcategories($subCategory); ?> <ul class="mm-submenu level3 getMmViewMode() ? 'vm-' . $subCategory->getMmViewMode() : 'vm-static'; ?>" data-mage-init='{"subMenuViewMode": {}}'> <?php for ($i = 0; $i current(); ?> getCssClass($curCategory); ?> <li class="item ui-menu-item"> getMmLabel()): ?> getImage($curCategory)) : ?> <img src="" alt=""> <a href="getUrl(); ?>">getName(); ?></a> next(); ?> $numberOfSubcategories): ?> <a href="getUrl(); ?>"></a> ```
    • Hello Can you provide a working file? I didn't get it to run. egards

Einen Kommentar schreiben