0

I have this error when I add special characters to menu or categories like "&" It's from module Ves Megamenu.

Warning: Invalid argument supplied for foreach() in /var/www/html/app/code/Ves/Megamenu/Model/Config/Source/StoreCategories.php on line 284

Warning Line:

$categoriesTrees = $this->getCategoriesTree();
foreach ($categoriesTrees as $category) {
    $this->generatCategory($category);
}
2

Solutions was to change this line to:

$categoriesTrees = $this->getCategoriesTree();
if(is_array($categoriesTrees)){
   foreach ($categoriesTrees as $category) {
       $this->generatCategory($category);
   }
}

Now I can use "&" or "/" in categories names, without crashing the site.

Useful source: https://thisinterestsme.com/invalid-argument-supplied-for-foreach/

| improve this answer | |
  • Good solution solved the issue for me as well +1 for that. – Remco Hendriks Mar 25 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.