怎么解决~~
MENU菜单比较奇怪 ,主菜单ID必须为1,在数据库中运行
DROP TABLE IF EXISTS `mgs_megamenu_parent`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `mgs_megamenu_parent` ( `parent_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Parent Id', `title` varchar(255) DEFAULT NULL COMMENT 'Title', `menu_type` smallint(6) NOT NULL DEFAULT '1' COMMENT 'Menu types', `custom_class` varchar(255) DEFAULT NULL COMMENT 'Custom class', `status` smallint(6) NOT NULL DEFAULT '1' COMMENT 'Status', PRIMARY KEY (`parent_id`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='mgs_megamenu_parent'; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `mgs_megamenu_parent` -- LOCK TABLES `mgs_megamenu_parent` WRITE; /*!40000 ALTER TABLE `mgs_megamenu_parent` DISABLE KEYS */; INSERT INTO `mgs_megamenu_parent` VALUES (1,'Main Menu',1,NULL,1),(2,'Vertical Menu Market',2,NULL,1),(3,'Vertical Menu Digital',2,NULL,1); /*!40000 ALTER TABLE `mgs_megamenu_parent` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `mgs_megamenu_store` -- DROP TABLE IF EXISTS `mgs_megamenu_store`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `mgs_megamenu_store` ( `megamenu_id` int(11) NOT NULL COMMENT 'Megamenu ID', `store_id` int(10) unsigned NOT NULL COMMENT 'Store ID', PRIMARY KEY (`megamenu_id`,`store_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='mgs_megamenu_store'; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `mgs_megamenu_store` -- LOCK TABLES `mgs_megamenu_store` WRITE; /*!40000 ALTER TABLE `mgs_megamenu_store` DISABLE KEYS */; INSERT INTO `mgs_megamenu_store` VALUES (1,0),(2,1),(2,2),(2,3),(2,4),(2,5),(2,6),(2,7),(2,8),(2,9),(2,11),(2,12),(2,13),(2,14),(2,16),(2,18),(2,20),(2,21),(3,1),(3,2),(3,3),(3,4),(3,5),(3,6),(3,7),(3,8),(3,9),(3,10),(3,11),(3,12),(3,13),(3,14),(3,15),(3,17),(3,18),(3,19),(3,20),(4,0),(5,0),(8,1),(8,2),(8,3),(8,4),(8,5),(8,7),(8,8),(8,9),(8,12),(8,13),(8,14),(8,15),(8,17),(9,0),(10,0),(11,0),(12,0),(14,0),(15,0),(16,0),(17,0),(18,0),(19,0),(20,0),(21,0),(22,0),(23,0),(24,0),(25,0),(26,0),(27,0),(28,0),(29,0),(30,0),(31,11),(32,11),(33,1),(33,2),(33,3),(33,4),(33,5),(33,7),(33,8),(33,9),(33,11),(33,12),(33,13),(33,14),(33,15),(33,17),(33,20),(33,21),(34,6),(34,10),(34,16),(34,18),(34,19),(34,22),(35,6),(35,16),(35,18),(35,19),(35,21); /*!40000 ALTER TABLE `mgs_megamenu_store` ENABLE KEYS */; UNLOCK TABLES;
完成菜单重置,不影响添加的主菜单的子菜单.
在2.4.6或是高版本PHP中会有报错,如
[2023-04-18T03:19:09.980987+00:00] main.CRITICAL: Exception: Deprecated Functionality: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /www/wwwroot/app/code/MGS/Mmegamenu/Block/Abstractmenu.php on line 311 in /www/wwwroot/vendor/magento/framework/App/ErrorHandler.php:62
打开 文件
/www/wwwroot/app/code/MGS/Mmegamenu/Block/Abstractmenu.php
修改代码
$subCatExist = explode(',', $item->getSubCategoryIds());
到
$subCatExist = explode(',', $item->getSubCategoryIds() ?? '');