
Magento 2.x – Add a CMS page entry through a database query without issues
With the following script, you will be able to add a new CMS page, withouth dealing with indexes or sequences problems.
1 2 3 4 5 6 7 8 9 10 11 |
SET @sequence_value := (SELECT MAX(sequence_value)+1 FROM sequence_cms_page); INSERT INTO sequence_cms_page (sequence_value) VALUES (@sequence_value); INSERT INTO cms_page (page_id, title, page_layout, meta_keywords, meta_description, identifier, content_heading, content, creation_time, update_time, is_active, sort_order, layout_update_xml, custom_theme, custom_root_template, custom_layout_update_xml, custom_theme_from, custom_theme_to, meta_title, created_in, updated_in, website_root, layout_update_selected) VALUES (@sequence_value, 'My Category', 'cms-full-width', '', '', 'my-category', '', '<div>This is the content</div>', '2023-01-24 22:23:24', '2023-01-31 20:06:34', 1, 0, null, '', null, null, null, null, '', 1, 2147483647, 1, null); |
Hope it helps.
Enjoy!