0

I need to add Megamenu via an install/upgrade script. I've added my megamenu. I've figured out which tables get updated when I add Megamenu.

The table which gets updated is

mgs_megamenu
mgs_megamenu_store

How can I achieve it programmatically like for cms block I referred this link for cms block

How to add a CMS block programmatically in Magento 2?

The queries which I prepared for megamenu, requires lots of insert and select

query1

INSERT INTO `mgs_megamenu` 
(`title`,`menu_type`,`category_id`,`position`,`columns`,
`dropdown_position`,`use_thumbnail`,`static_content`,
`left_col`,`right_col`,`status`,`parent_id`,`store`) VALUES 
('WHAT''S NEW',2,0,0,6,1,2,'<div class="mega-menu-content">
</div>',1,1,1,1,0);  

query2

SET @mgs_megamenu_id = (SELECT max(megamenu_id) FROM mgs_megamenu);

query3

INSERT INTO `mgs_megamenu_store` (`megamenu_id`,`store_id`) VALUES (@mgs_megamenu_id ,0);

Modal class of MGS is MGS\Mpanel\Model\Category;

2
  • Please share the Model class of that module
    – Amit Bera
    Commented Jan 30, 2019 at 11:13
  • Its a big file, so i have given the path
    – summu
    Commented Jan 30, 2019 at 11:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.