Friday, June 8, 2018
Opencart 2 x save settings for module or add module to layout
Opencart 2 x save settings for module or add module to layout
//loading the settings
$this->load->model(setting/setting);
$setting = $this->model_setting_setting->getSetting(mymodule);
//saving the settings
$this->load->model(setting/setting);
$setting = $this->model_setting_setting->editSetting(mymodule);
NOTE: in the form the input name="" must start with the name of the module. Example: mymodule_limit, mymodule_status, mymodule_othersetting
//getting data from the module - usually is loaded by the configured layout
$this->load->model(extension/module);
$setting = $this->model_extension_module->getModuleByCode(mymodule);
//saving data for the module with new id from the POST (saves a new one that can be loaded from the layout)
$this->load->model(extension/module);
if (!isset($this->request->get[module_id])) { // $this->model_extension_module->addModule(mymodule, $this->request->post);
} else {
$this->model_extension_module->editModule($this->request->get[module_id], $this->request->post);
}