15 minutes ago, D. Tengler said:It's not so easy.
SQL queries must be used.
It is impossible to write the whole code here.
Just look at the tables in the database and then everything will be clear.Např.:
// table ps_cms // // cms position $cms_position = Db::getInstance()->getValue('SELECT position FROM '._DB_PREFIX_.'cms ORDER BY position DESC') + 1; // cms category $cms_category = 1; // cms active $cms_active = 1; // cms indexation $cms_indexation = 1; // create cms id $cms = Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'cms (id_cms_category, position, active, indexation) VALUES ($cms_category, $cms_position, $cms_active, $cms_indexation)'); // inserted cms id $cms_id = Db::getInstance()->Insert_ID(); // table ps_cmas_lang // // cms for multistore $cms_shops = array(1,2); // cms for actual store $cms_shop = (int)Context::getContext()->shop->id; // cms languages for multistore $cms_langs_stores = Language::getLanguages(true); // cms languages for current store $cms_langs = Language::getLanguages(true, $this->context->shop->id); // cms current language $cms_lang = (int)Context::getContext()->language->id; $cms_meta_title = 'your metatitle'; $cms_seo_head_titile = 'your head seo titile'; $cms_meta_description = 'your meta description'; $cms_meta_keywords = 'your,meta,keywords'; $cms_content = 'your html content'; $cms_link_rewrite = 'your-link-rewrite'; // create cms page content Db::getInstance()->Execute("INSERT INTO "._DB_PREFIX_."cms_lang (id_cms, id_lang, id_shop, meta_title, head_so_title, meta_description, meta_keywords, content, link_rewrite) VALUES ($cms_id, $cms_lang, $cms_shop, '".$cms_meta_title."', '".$cms_seo_head_titile."', '".$cms_meta_description."', '".$cms_meta_keywords."', '".$cms_content."', '".$cms_link_rewrite."')"); // associate created cms page to shop Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'cms_shop (id_cms, id_shop) VALUES ($cms_id,$cms_shop);If you want to add more languages and more shops, you have to use foreach.
Thanks a lot! I modified your code already from your previous post for my needs.
Thanks a lot for your help, I think soon I will create full tutorial how to create cms pages from module.